|
| 1 | +name: Create and publish the CI docker image |
| 2 | + |
| 3 | +# Configures this workflow to run when triggered. |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - v** |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +# Defines two custom environment variables for the workflow. These are used for |
| 11 | +# the Container registry domain, and a name for the Docker image that this |
| 12 | +# workflow builds. |
| 13 | +env: |
| 14 | + REGISTRY: ghcr.io |
| 15 | + IMAGE_NAME: twsearle/orca-jedi/ci-almalinux9 |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-push-image: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: write |
| 24 | + attestations: write |
| 25 | + id-token: write |
| 26 | + # |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + # Uses the `docker/login-action` action to log in to the Container |
| 31 | + # registry registry using the account and password that will publish the |
| 32 | + # packages. Once published, the packages are scoped to the account |
| 33 | + # defined here. |
| 34 | + - name: Log in to the Container registry |
| 35 | + uses: docker/login-action@v3 |
| 36 | + with: |
| 37 | + registry: ${{ env.REGISTRY }} |
| 38 | + username: twsearle |
| 39 | + password: ${{ secrets.GHCR_PAT }} |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + # This step uses |
| 43 | + # [docker/metadata-action](https://github.com/docker/metadata-action#about) |
| 44 | + # to extract tags and labels that will be applied to the specified image. |
| 45 | + # The `id` "meta" allows the output of this step to be referenced in a |
| 46 | + # subsequent step. The `images` value provides the base name for the tags |
| 47 | + # and labels. |
| 48 | + - name: Extract metadata (tags, labels) for Docker |
| 49 | + id: meta |
| 50 | + uses: docker/metadata-action@v5 |
| 51 | + with: |
| 52 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 53 | + - name: Install hpccm |
| 54 | + run: | |
| 55 | + python3 -m pip install hpccm |
| 56 | + - name: Recipe to Dockerfile |
| 57 | + run: | |
| 58 | + hpccm --recipe ./ci/hpccm_recipe_almalinux9.py >./Dockerfile |
| 59 | + # This step uses the `docker/build-push-action` action to build the |
| 60 | + # image, based on your repository's `Dockerfile`. If the build succeeds, |
| 61 | + # it pushes the image to GitHub Packages. It uses the `context` |
| 62 | + # parameter to define the build's context as the set of files located in |
| 63 | + # the specified path. For more information, see |
| 64 | + # "[Usage](https://github.com/docker/build-push-action#usage)" in the |
| 65 | + # README of the `docker/build-push-action` repository. It uses the |
| 66 | + # `tags` and `labels` parameters to tag and label the image with the |
| 67 | + # output from the "meta" step. |
| 68 | + - name: Build and push Docker image |
| 69 | + id: push |
| 70 | + uses: docker/build-push-action@v6 |
| 71 | + with: |
| 72 | + context: . |
| 73 | + cache-from: type=gha |
| 74 | + cache-to: type=gha,mode=max` |
| 75 | + push: true |
| 76 | + tags: ${{ steps.meta.outputs.tags }} |
| 77 | + labels: ${{ steps.meta.outputs.labels }} |
| 78 | + |
| 79 | + |
| 80 | + # This step generates an artifact attestation for the image, which is an |
| 81 | + # unforgeable statement about where and how it was built. It increases |
| 82 | + # supply chain security for people who consume the image. For more |
| 83 | + # information, see |
| 84 | + # "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." |
| 85 | + - name: Generate artifact attestation |
| 86 | + uses: actions/attest-build-provenance@v1 |
| 87 | + with: |
| 88 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 89 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 90 | + push-to-registry: true |
0 commit comments