-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to ssh key for private requirements_git (#15838)
- Loading branch information
1 parent
4487f2a
commit 8145de3
Showing
5 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ inputs: | |
github-token: | ||
description: GitHub Token for registry access | ||
required: true | ||
private-github-token: | ||
description: GitHub Token for private repositories | ||
private-github-key: | ||
description: GitHub private key for private repositories | ||
required: false | ||
default: '' | ||
runs: | ||
|
@@ -26,10 +26,26 @@ runs: | |
run: | | ||
echo "${{ inputs.github-token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Add Private github token to requirements_git.credentials.txt | ||
- name: Generate placeholder SSH private key if SSH auth for private repos is not needed | ||
id: generate_key | ||
shell: bash | ||
run: echo "https://x-access-token:${{ inputs.private-github-token }}@github.com" >> requirements/requirements_git.credentials.txt | ||
if: ${{ inputs.private-github-token != '' }} | ||
run: | | ||
if [[ -z "${{ inputs.private-github-key }}" ]]; then | ||
ssh-keygen -t ed25519 -C "github-actions" -N "" -f ~/.ssh/id_ed25519 | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
cat ~/.ssh/id_ed25519 >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
else | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
echo "${{ inputs.private-github-key }}" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Add private GitHub key to SSH agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ steps.generate_key.outputs.SSH_PRIVATE_KEY }} | ||
|
||
|
||
- name: Pre-pull latest devel image to warm cache | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ name: CI | |
env: | ||
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting | ||
CI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CI_PRIVATE_GITHUB_TOKEN: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | ||
DEV_DOCKER_OWNER: ${{ github.repository_owner }} | ||
COMPOSE_TAG: ${{ github.base_ref || 'devel' }} | ||
UPSTREAM_REPOSITORY_ID: 91594105 | ||
|
@@ -55,7 +54,7 @@ jobs: | |
uses: ./.github/actions/awx_devel_image | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | ||
private-github-key: ${{ secrets.PRIVATE_GITHUB_KEY }} | ||
|
||
- name: Run check ${{ matrix.tests.name }} | ||
id: make-run | ||
|
@@ -140,7 +139,7 @@ jobs: | |
with: | ||
build-ui: false | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | ||
private-github-key: ${{ secrets.PRIVATE_GITHUB_KEY }} | ||
|
||
- name: Run live dev env tests | ||
run: docker exec tools_awx_1 /bin/bash -c "make live_test" | ||
|
@@ -182,11 +181,25 @@ jobs: | |
run: | | ||
python3 -m pip install docker | ||
- name: Add Private github token to requirements_git.credentials.txt | ||
- name: Generate placeholder SSH private key if SSH auth for private repos is not needed | ||
id: generate_key | ||
shell: bash | ||
working-directory: awx | ||
run: echo "https://x-access-token:${{ env.CI_PRIVATE_GITHUB_TOKEN }}@github.com" >> requirements/requirements_git.credentials.txt | ||
if: ${{ env.CI_PRIVATE_GITHUB_TOKEN != '' }} | ||
run: | | ||
if [[ -z "${{ secrets.PRIVATE_GITHUB_KEY }}" ]]; then | ||
ssh-keygen -t ed25519 -C "github-actions" -N "" -f ~/.ssh/id_ed25519 | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
cat ~/.ssh/id_ed25519 >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
else | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
echo "${{ secrets.PRIVATE_GITHUB_KEY }}" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Add private GitHub key to SSH agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ steps.generate_key.outputs.SSH_PRIVATE_KEY }} | ||
|
||
- name: Build AWX image | ||
working-directory: awx | ||
|
@@ -295,7 +308,7 @@ jobs: | |
with: | ||
build-ui: false | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | ||
private-github-key: ${{ secrets.PRIVATE_GITHUB_KEY }} | ||
|
||
- name: Install dependencies for running tests | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ name: Build/Push Development Images | |
env: | ||
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting | ||
DOCKER_CACHE: "--no-cache" # using the cache will not rebuild git requirements and other things | ||
CI_PRIVATE_GITHUB_TOKEN: ${{ secrets.PRIVATE_GITHUB_TOKEN }} | ||
on: | ||
workflow_dispatch: | ||
push: | ||
|
@@ -74,10 +73,25 @@ jobs: | |
make ui | ||
if: matrix.build-targets.image-name == 'awx' | ||
|
||
- name: Add private GitHub token to requirements_git.credentials.txt | ||
- name: Generate placeholder SSH private key if SSH auth for private repos is not needed | ||
id: generate_key | ||
shell: bash | ||
run: echo "https://x-access-token:${{ secrets.PRIVATE_GITHUB_TOKEN }}@github.com" >> requirements/requirements_git.credentials.txt | ||
if: ${{ env.CI_PRIVATE_GITHUB_TOKEN != '' }} | ||
run: | | ||
if [[ -z "${{ secrets.PRIVATE_GITHUB_KEY }}" ]]; then | ||
ssh-keygen -t ed25519 -C "github-actions" -N "" -f ~/.ssh/id_ed25519 | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
cat ~/.ssh/id_ed25519 >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
else | ||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_OUTPUT | ||
echo "${{ secrets.PRIVATE_GITHUB_KEY }}" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Add private GitHub key to SSH agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ steps.generate_key.outputs.SSH_PRIVATE_KEY }} | ||
|
||
- name: Build and push AWX devel images | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters