|
| 1 | +name: Build & Push e2e-runner Image to Quay.io |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release-1.** |
| 8 | + paths: |
| 9 | + - '.ibm/images/Dockerfile' |
| 10 | + - '.yarnrc.yml' |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + branch: |
| 14 | + description: Target branch to build |
| 15 | + required: true |
| 16 | + default: 'NONE' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +env: |
| 23 | + REGISTRY: quay.io |
| 24 | + REGISTRY_IMAGE: rhdh-community/rhdh-e2e-runner |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-image: |
| 28 | + name: Build & Push e2e-runner Image |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: [ubuntu-24.04] |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + packages: write |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout Repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + |
| 44 | + - name: Prepare Environment Variables |
| 45 | + run: | |
| 46 | + echo "PLATFORM=linux/amd64" >> $GITHUB_ENV |
| 47 | +
|
| 48 | + # create image tag from the correct branch (either from a push or a workflow_dispatch trigger) |
| 49 | + if [[ "${{ inputs.branch }}" ]] && [[ "${{ inputs.branch }}" != "NONE" ]]; then |
| 50 | + echo "Switch to ${{ inputs.branch }}" |
| 51 | + git checkout "${{ inputs.branch }}" |
| 52 | + IMAGE_TAG="${{ inputs.branch }}" |
| 53 | + else |
| 54 | + echo "Use current branch ${{ github.ref }}" |
| 55 | + IMAGE_TAG=$(git rev-parse --abbrev-ref HEAD) |
| 56 | + fi |
| 57 | + echo "Use IMAGE_TAG = $IMAGE_TAG" |
| 58 | + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV |
| 59 | +
|
| 60 | + - name: Get the last commit short SHA |
| 61 | + uses: ./.github/actions/get-sha |
| 62 | + |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v3 |
| 65 | + |
| 66 | + - name: Login to Quay.io |
| 67 | + uses: docker/login-action@v3 |
| 68 | + with: |
| 69 | + registry: ${{ env.REGISTRY }} |
| 70 | + username: ${{ secrets.QUAY_USERNAME }} |
| 71 | + password: ${{ secrets.QUAY_TOKEN }} |
| 72 | + |
| 73 | + - name: Build and Push Image |
| 74 | + uses: docker/build-push-action@v5 |
| 75 | + with: |
| 76 | + context: . |
| 77 | + file: .ibm/images/Dockerfile |
| 78 | + push: true |
| 79 | + tags: | |
| 80 | + ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} |
| 81 | + ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}-${{ env.SHORT_SHA }} |
| 82 | + platforms: ${{ env.PLATFORM }} |
0 commit comments