Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to provide auth to private repo for requirements_git in container build #15831

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actions/awx_devel_image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
github-token:
description: GitHub Token for registry access
required: true
private-github-token:
description: GitHub Token for private repositories
required: false
default: ''
runs:
using: composite
steps:
Expand All @@ -22,6 +26,11 @@ 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
shell: bash
run: echo "https://x-access-token:${{ inputs.private-github-token }}@github.com" >> requirements/requirements_git.credentials.txt
if: ${{ inputs.private-github-token != '' }}

- name: Pre-pull latest devel image to warm cache
shell: bash
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/actions/run_awx_devel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
required: false
default: false
type: boolean
private-github-token:
description: GitHub Token for private repositories
required: false
default: ''
outputs:
ip:
description: The IP of the tools_awx_1 container
Expand All @@ -28,6 +32,7 @@ runs:
uses: ./.github/actions/awx_devel_image
with:
github-token: ${{ inputs.github-token }}
private-github-token: ${{ inputs.private-github-token}}

- name: Upgrade ansible-core
shell: bash
Expand Down Expand Up @@ -69,4 +74,4 @@ runs:
shell: bash
run: |
AWX_IP=$(docker inspect -f '{{.NetworkSettings.Networks.awx.IPAddress}}' tools_awx_1)
echo "ip=$AWX_IP" >> $GITHUB_OUTPUT
echo "ip=$AWX_IP" >> $GITHUB_OUTPUT
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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
Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
uses: ./.github/actions/awx_devel_image
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}

- name: Run check ${{ matrix.tests.name }}
id: make-run
Expand Down Expand Up @@ -138,6 +140,7 @@ jobs:
with:
build-ui: false
github-token: ${{ secrets.GITHUB_TOKEN }}
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}

- name: Run live dev env tests
run: docker exec tools_awx_1 /bin/bash -c "make live_test"
Expand Down Expand Up @@ -179,6 +182,12 @@ jobs:
run: |
python3 -m pip install docker

- name: Add Private github token to requirements_git.credentials.txt
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 != '' }}

- name: Build AWX image
working-directory: awx
run: |
Expand Down Expand Up @@ -286,6 +295,7 @@ jobs:
with:
build-ui: false
github-token: ${{ secrets.GITHUB_TOKEN }}
private-github-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}

- name: Install dependencies for running tests
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/devel_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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:
Expand Down Expand Up @@ -73,6 +74,11 @@ jobs:
make ui
if: matrix.build-targets.image-name == 'awx'

- name: Add private GitHub token to requirements_git.credentials.txt
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 != '' }}

- name: Build and push AWX devel images
run: |
make ${{ matrix.build-targets.make-target }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ reports
local/
*.mo
requirements/vendor
requirements/requirements_git.credentials.txt
.i18n_built
.idea/*
*credentials*.y*ml*
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ include COPYING
include Makefile
prune awx/public
prune awx/projects
prune requirements/requirements_git.credentials.txt
2 changes: 2 additions & 0 deletions requirements/requirements_git.credentials.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# If sources in requirements_git.txt require authentication add git-credentials in this file, Example:
# https://x-access-token:${PAT}@github.com"
4 changes: 4 additions & 0 deletions tools/ansible/roles/dockerfile/templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ RUN mkdir /tmp/requirements
ADD requirements/requirements.txt \
requirements/requirements_tower_uninstall.txt \
requirements/requirements_git.txt \
requirements/requirements_git.credentials.txt \
/tmp/requirements/

RUN git config --global credential.helper "store --file=/tmp/requirements/requirements_git.credentials.txt"
RUN cd /tmp && make requirements_awx

ARG VERSION
Expand All @@ -102,6 +104,8 @@ RUN DJANGO_SETTINGS_MODULE=awx.settings.defaults SKIP_SECRET_KEY_CHECK=yes SKIP_

{% endif %}

RUN rm /tmp/requirements/requirements_git.credentials.txt

# Final container(s)
FROM quay.io/centos/centos:stream9

Expand Down
Loading