Build and push Trustee container image #77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Build and push Trustee container image" | |
| env: | |
| NAME: "trustee" | |
| REGISTRY: "quay.io/trusted-execution-clusters" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'containerfiles/trustee.container' | |
| - '.github/workflows/build-trustee-image.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'containerfiles/trustee.container' | |
| - '.github/workflows/build-trustee-image.yml' | |
| schedule: | |
| - cron: '0 0 * * MON' | |
| workflow_dispatch: | |
| permissions: read-all | |
| # Prevent multiple workflow runs from racing to ensure that pushes are made | |
| # sequentially for the main branch. Also cancel in progress workflow runs for | |
| # pull requests only. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-trustee-image: | |
| ## TODO REMOVE this false to let the job running again once the compilation | |
| # for trustee on rawhide is fixed | |
| if: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get latest commit from trustee repo | |
| id: get-upstream-commit | |
| run: | | |
| UPSTREAM_SHA=$(git ls-remote https://github.com/confidential-containers/trustee.git HEAD | cut -f1) | |
| SHORT_SHA=$(echo $UPSTREAM_SHA | cut -c1-7) | |
| echo "sha=${UPSTREAM_SHA}" >> $GITHUB_OUTPUT | |
| echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| - name: Generate image tag | |
| id: generate-tag | |
| run: | | |
| TAG="${{ steps.get-upstream-commit.outputs.short_sha }}" | |
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
| - name: Build Trustee image | |
| id: build-image | |
| uses: redhat-actions/buildah-build@v2 | |
| with: | |
| image: ${{ env.NAME }} | |
| tags: ${{ steps.generate-tag.outputs.tag }} | |
| containerfiles: | | |
| containerfiles/trustee.container | |
| context: containerfiles | |
| oci: true | |
| build-args: | | |
| COMMIT=${{ steps.get-upstream-commit.outputs.sha }} | |
| - name: Push to Container Registry | |
| uses: redhat-actions/push-to-registry@v2 | |
| if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && github.ref == 'refs/heads/main' && github.repository_owner == 'trusted-execution-clusters' | |
| with: | |
| image: ${{ steps.build-image.outputs.image }} | |
| tags: ${{ steps.generate-tag.outputs.tag }} | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_PASSWORD }} |