|
1 | | -name: Release |
| 1 | +--- |
| 2 | +# This workflow will build and push an AWX EE image to a container registry based upon the provided configuration |
| 3 | +# |
| 4 | +# Image tags will be generated based upon the event that triggered the workflow: |
| 5 | +# - push event: |
| 6 | +# - main branch: latest |
| 7 | +# - devel branch: devel |
| 8 | +# - all other branches: <branch name>-latest |
| 9 | +# Branches must be added to the on.push.branches array above to trigger |
| 10 | +# - pull_request event: DEV-PR-<pull_request_number> |
| 11 | +# Branches must be added to the on.pull_request.branches array above to trigger |
| 12 | +# - release event: <tag_name> |
| 13 | +# - schedule event: nightly |
| 14 | +# This will be the same configuration as the 'latest' tag, but may contain updated packages, etc. from upstream |
| 15 | +# - all other events: <first 7 chars of commit sha> |
| 16 | +# |
| 17 | +# Variables: |
| 18 | +# IMAGE_REGISTRY_URL: The container registry to push the image to (default: ghcr.io) |
| 19 | +# IMAGE_REPOSITORY: The repository to push the image to (default: github.repository) |
| 20 | +# IMAGE_REGISTRY_USER: The username to authenticate with the container registry (default: github.actor) |
| 21 | +# |
| 22 | +# Secrets: |
| 23 | +# IMAGE_REGISTRY_TOKEN: The token to authenticate with the container registry (default: secrets.GITHUB_TOKEN) |
| 24 | +# |
| 25 | + |
| 26 | +name: Build & Release |
2 | 27 |
|
3 | 28 | on: |
| 29 | + push: |
| 30 | + # build and push anytime commits are merged to specified branches |
| 31 | + branches: |
| 32 | + - main |
| 33 | + - devel |
| 34 | + paths: |
| 35 | + - ".github/workflows/release.yml" |
| 36 | + - "./**" |
| 37 | + - '!**/*.md' |
| 38 | + pull_request: |
| 39 | + # build and push anytime a pull request is opened or synchronized |
| 40 | + branches: |
| 41 | + - main |
| 42 | + - devel |
| 43 | + paths: |
| 44 | + - ".github/workflows/release.yml" |
| 45 | + - "./**" |
| 46 | + - '!**/*.md' |
4 | 47 | release: |
| 48 | + # build and push anytime a release is created |
5 | 49 | types: |
6 | 50 | - created |
| 51 | + schedule: |
| 52 | + # build and push nightly |
| 53 | + - cron: "13 4 * * *" |
7 | 54 |
|
8 | 55 | jobs: |
| 56 | + ci: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + name: CI Build (Podman) |
| 59 | + strategy: |
| 60 | + fail-fast: true |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - uses: actions/setup-python@v5 |
| 65 | + with: |
| 66 | + python-version: "3.12" |
| 67 | + |
| 68 | + - name: Install dependencies |
| 69 | + run: | |
| 70 | + python -m pip install --upgrade pip setuptools |
| 71 | + pip install -r requirements.txt |
| 72 | +
|
| 73 | + - name: Build EE with Podman |
| 74 | + run: | |
| 75 | + ansible-builder build -v3 -t ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }} --container-runtime=podman |
| 76 | +
|
9 | 77 | release: |
10 | | - runs-on: ubuntu-22.04 |
| 78 | + runs-on: ubuntu-latest |
11 | 79 | name: Release |
| 80 | + strategy: |
| 81 | + fail-fast: true |
12 | 82 | steps: |
13 | 83 | - uses: actions/checkout@v4 |
14 | 84 |
|
|
21 | 91 | python -m pip install --upgrade pip setuptools |
22 | 92 | pip install -r requirements.txt |
23 | 93 |
|
24 | | - - name: Quay login |
| 94 | + - name: Login to Docker Container Registry |
| 95 | + uses: docker/login-action@v3 |
| 96 | + with: |
| 97 | + registry: ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }} |
| 98 | + username: ${{ vars.IMAGE_REGISTRY_USER || github.actor }} |
| 99 | + password: ${{ secrets.IMAGE_REGISTRY_TOKEN || secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Generate image tag |
25 | 102 | run: | |
26 | | - echo "${{ secrets.QUAY_TOKEN }}" | docker login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin |
| 103 | + if [[ "${{ github.event_name }}" == "push" ]]; then |
| 104 | + if [[ "${{ github.ref_name }}" == "main" ]]; then |
| 105 | + echo "IMAGE_TAG=latest" >> $GITHUB_ENV |
| 106 | + elif [[ "${{ github.ref_name }}" == "devel" ]]; then |
| 107 | + echo "IMAGE_TAG=devel" >> $GITHUB_ENV |
| 108 | + else |
| 109 | + echo "IMAGE_TAG=${{ github.ref_name }}-latest" >> $GITHUB_ENV |
| 110 | + fi |
| 111 | + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 112 | + echo "IMAGE_TAG=DEV-PR-${{ github.event.pull_request.number }}" >> $GITHUB_ENV |
| 113 | + elif [[ "${{ github.event_name }}" == "release" ]]; then |
| 114 | + echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV |
| 115 | + elif [[ "${{ github.event_name }}" == "schedule" ]]; then |
| 116 | + echo "IMAGE_TAG=nightly" >> $GITHUB_ENV |
| 117 | + else |
| 118 | + echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV |
| 119 | + fi |
27 | 120 |
|
28 | 121 | - name: Build and push image |
29 | 122 | run: | |
|
33 | 126 | docker buildx build \ |
34 | 127 | --push \ |
35 | 128 | --platform=linux/amd64,linux/arm64 \ |
36 | | - --tag=${{ vars.IMAGE_REGISTRY }}:${{ github.event.release.tag_name }} \ |
| 129 | + --tag=${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }} \ |
37 | 130 | context |
38 | 131 |
|
0 commit comments