|
| 1 | +name: CI build and push |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ci-${{ github.run_id }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - v[0-9]+ |
| 13 | + - v[0-9]+.[0-9]+ |
| 14 | + - cryostat-v[0-9]+.[0-9]+ |
| 15 | + |
| 16 | +env: |
| 17 | + CI_USER: cryostat+bot |
| 18 | + CI_REGISTRY: quay.io/cryostat |
| 19 | + CI_IMG: quay.io/cryostat/openshift-oauth-proxy |
| 20 | + REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} |
| 21 | + REF: ${{ github.event.pull_request.head.ref }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + - name: Install qemu |
| 29 | + continue-on-error: false |
| 30 | + run: | |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install -y qemu-user-static |
| 33 | + - name: Get date tag |
| 34 | + run: echo "DATE_TAG=$(date -uI)" >> "$GITHUB_ENV" |
| 35 | + - name: Check release branch |
| 36 | + id: check-branch |
| 37 | + run: | |
| 38 | + if [[ ${REF_NAME} == cryostat-v* ]]; then |
| 39 | + echo "image-tag=${REF_NAME:10}-dev" >> $GITHUB_OUTPUT |
| 40 | + else |
| 41 | + echo "image-tag=${REF_NAME}" >> $GITHUB_OUTPUT |
| 42 | + fi |
| 43 | + - name: Check commit git tag |
| 44 | + id: check-commit |
| 45 | + run: | |
| 46 | + output=$(git describe --tags --exact-match 2>/dev/null | sed -e "s/^v//" || echo -n '') |
| 47 | + echo "::set-output name=image-tag::$output" |
| 48 | + echo "::set-output name=image-tag-patch::${output:0:3}" |
| 49 | + echo "::set-output name=image-tag-release::${output:0:1}" |
| 50 | + - name: Build container images and manifest |
| 51 | + id: buildah-build |
| 52 | + uses: redhat-actions/buildah-build@v2 |
| 53 | + with: |
| 54 | + image: ${{ env.CI_IMG }} |
| 55 | + archs: amd64, arm64 |
| 56 | + tags: ${{ github.ref_name }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }} ${{ env.DATE_TAG }} ${{ steps.check-branch.outputs.image-tag }} ${{ steps.check-commit.outputs.image-tag }} ${{ steps.check-commit.outputs.image-tag-patch }} ${{ steps.check-commit.outputs.image-tag-release }} |
| 57 | + containerfiles: | |
| 58 | + ./Containerfile |
| 59 | + - name: Push to quay.io |
| 60 | + id: push-to-quay |
| 61 | + uses: redhat-actions/push-to-registry@v2 |
| 62 | + with: |
| 63 | + image: openshift-oauth-proxy |
| 64 | + tags: ${{ steps.buildah-build.outputs.tags }} |
| 65 | + registry: ${{ env.CI_REGISTRY }} |
| 66 | + username: ${{ env.CI_USER }} |
| 67 | + password: ${{ secrets.REGISTRY_PASSWORD }} |
| 68 | + if: ${{ github.repository_owner == 'cryostatio' }} |
| 69 | + - name: Print image URL |
| 70 | + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" |
| 71 | + if: ${{ github.repository_owner == 'cryostatio' }} |
0 commit comments