ricolin | cc4a0f0 | 2023-08-03 11:27:22 +0800 | [diff] [blame] | 1 | name: build |
| 2 | concurrency: |
| 3 | group: ${{ github.head_ref || github.run_id }} |
| 4 | cancel-in-progress: true |
| 5 | on: |
| 6 | workflow_dispatch: |
| 7 | inputs: |
| 8 | image_push: |
| 9 | type: boolean |
| 10 | description: 'Push images to Container Registry' |
| 11 | required: false |
| 12 | default: false |
| 13 | pull_request: |
| 14 | types: |
| 15 | - opened |
| 16 | - synchronize |
| 17 | - reopened |
| 18 | push: |
| 19 | branches: |
| 20 | - main |
| 21 | jobs: |
| 22 | image: |
| 23 | runs-on: ubuntu-latest |
| 24 | strategy: |
| 25 | matrix: |
| 26 | from: |
| 27 | - jammy |
| 28 | release: |
| 29 | - "2023.1" |
| 30 | steps: |
| 31 | - name: Install QEMU static binaries |
| 32 | uses: docker/setup-qemu-action@v2 |
| 33 | - name: Configure Buildkit |
| 34 | uses: docker/setup-buildx-action@v2 |
| 35 | - name: Checkout project |
| 36 | uses: actions/checkout@v3 |
| 37 | - name: Setup environment variables |
| 38 | run: echo "PROJECT_REF=${{ github.sha }}" >> "$GITHUB_ENV" |
| 39 | - name: Authenticate with Quay.io |
| 40 | uses: docker/login-action@v2 |
| 41 | if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.image_push == true) }} |
| 42 | with: |
| 43 | password: ${{ secrets.QUAY_ROBOT_TOKEN }} |
| 44 | registry: quay.io |
| 45 | username: ${{ secrets.QUAY_USERNAME }} |
| 46 | - name: Build image |
| 47 | uses: docker/build-push-action@v3 |
| 48 | with: |
| 49 | build-args: |- |
| 50 | BUILDER_IMAGE=quay.io/vexxhost/openstack-builder-${{ matrix.from }} |
| 51 | RUNTIME_IMAGE=quay.io/vexxhost/openstack-runtime-${{ matrix.from }} |
| 52 | RELEASE=${{ matrix.release }} |
| 53 | PROJECT=staffln |
| 54 | PROJECT_REPO=https://github.com/vexxhost/staffeln |
| 55 | PROJECT_REF=${{ env.PROJECT_REF }} |
| 56 | cache-from: type=gha,scope=${{ matrix.from }}-${{ matrix.release }} |
| 57 | cache-to: type=gha,mode=max,scope=${{ matrix.from }}-${{ matrix.release }} |
| 58 | context: . |
| 59 | platforms: linux/amd64 |
| 60 | push: ${{ github.event_name == 'push' || inputs.image_push == true }} |
| 61 | tags: quay.io/vexxhost/staffeln:${{ env.PROJECT_REF }}-${{ matrix.from }} |
| 62 | - name: Promote image |
| 63 | uses: akhilerm/tag-push-action@v2.0.0 |
| 64 | if: github.event_name == 'push' && ((matrix.from == 'focal') || (matrix.from == 'jammy' && matrix.release != 'yoga')) |
| 65 | with: |
| 66 | dst: quay.io/vexxhost/staffeln:${{ matrix.release }} |
| 67 | src: quay.io/vexxhost/staffeln:${{ env.PROJECT_REF }}-${{ matrix.from }} |