Skip to content

Commit

Permalink
Modify Release GHA to run on fork
Browse files Browse the repository at this point in the history
  • Loading branch information
rooftopcellist committed Jan 16, 2024
1 parent 9442e0a commit 737abd7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 30 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Fail if QUAY_REGISTRY not set
run: |
if [[ -z "${{ vars.QUAY_REGISTRY }}" ]]; then
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
exit 1
fi
- name: Log into registry ghcr.io
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
Expand All @@ -24,18 +31,18 @@ jobs:
- name: Log into registry quay.io
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: quay.io/ansible/
registry: ${{ vars.QUAY_REGISTRY }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}


- name: Build and Store Image @ghcr
run: |
IMG=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.sha }} make docker-buildx
IMG=ghcr.io/${{ github.repository }}:${{ github.sha }} make docker-buildx
- name: Publish Image to quay.io/ansible/awx-operator:devel
- name: Publish Image to quay.io
run: |
docker buildx imagetools create \
ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.sha }} \
--tag quay.io/ansible/${{ github.repository }}:devel
ghcr.io/${{ github.repository }}:${{ github.sha }} \
--tag ${{ vars.QUAY_REGISTRY }}/awx-operator:devel
36 changes: 25 additions & 11 deletions .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,35 @@ on:
tag_name:
description: 'Name for the tag of the release.'
required: true
quay_registry:
description: 'Quay registry to push to.'
default: 'quay.io/ansible'

env:
QUAY_REGISTRY: ${{ vars.QUAY_REGISTRY }}

jobs:
promote:
runs-on: ubuntu-latest
steps:
- name: Set TAG_NAME for workflow_dispatch event
- name: Set GitHub Env vars for workflow_dispatch event
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
echo "QUAY_REGISTRY=${{ github.event.inputs.quay_registry }}" >> $GITHUB_ENV
- name: Set TAG_NAME for release event
if: ${{ github.event_name == 'release' }}
- name: Set GitHub Env vars if release event and vars.QUAY_REGISTRY is not set
if: ${{ github.event_name == 'release' && !vars.QUAY_REGISTRY }}
run: |
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
- name: Fail if QUAY_REGISTRY not set
run: |
if [[ -z "${{ env.QUAY_REGISTRY }}" ]]; then
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
exit 1
fi
- uses: actions/checkout@v3
with:
depth: 0
Expand All @@ -39,29 +53,29 @@ jobs:
- name: Log into registry quay.io
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: quay.io/ansible/
registry: ${{ env.QUAY_REGISTRY }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}


- name: Pull Stored Image and Publish to quay.io/${{ github.repository }}:${TAG_NAME}
- name: Pull Tagged Staged Image and Publish to quay.io
run: |
docker buildx imagetools create \
ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${TAG_NAME} \
--tag quay.io/ansible/${{ github.repository }}:${TAG_NAME}
ghcr.io/${{ github.repository }}:${TAG_NAME} \
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:${TAG_NAME}
- name: Pull Stored Image and Publish to quay.io/${{ github.repository }}:latest
- name: Pull Staged Image and Publish to quay.io/${{ github.repository }}:latest
run: |
docker buildx imagetools create \
ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${TAG_NAME} \
--tag quay.io/ansible/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${TAG_NAME} \
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:latest
- name: Release Helm chart
run: |
ansible-playbook ansible/helm-release.yml -v \
-e operator_image=quay.io/${{ github.repository }} \
-e operator_image=${{ env.QUAY_REGISTRY }}/awx-operator \
-e chart_owner=${{ github.repository_owner }} \
-e tag=${TAG_NAME} \
-e gh_token=${{ secrets.GITHUB_TOKEN }} \
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ jobs:
exit 0
- name: Checkout awx
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/awx
path: awx

- name: Checkout awx-operator
uses: actions/checkout@v3
with:
Expand All @@ -61,10 +55,11 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Stage awx-operator
working-directory: awx-operator
run: |
BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.default_awx_version }} \
--build-arg OPERATOR_VERSION=${{ github.event.inputs.version }}" \
IMG=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.event.inputs.version }} \
IMG=ghcr.io/${{ github.repository }}:${{ github.event.inputs.version }} \
make docker-buildx
- name: Run test deployment
Expand All @@ -78,10 +73,12 @@ jobs:
env:
AWX_TEST_VERSION: ${{ github.event.inputs.default_awx_version }}

- name: Create draft release
working-directory: awx
run: |
ansible-playbook tools/ansible/stage.yml \
-e version=${{ github.event.inputs.version }} \
-e repo=${{ github.repository_owner }}/awx-operator \
-e github_token=${{ secrets.GITHUB_TOKEN }}
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
draft: true

0 comments on commit 737abd7

Please sign in to comment.