|
| 1 | +name: Publishes the test-ubuntu-git Container Image |
| 2 | + |
| 3 | +on: |
| 4 | + # Use an on demand workflow trigger. |
| 5 | + # (Forked copies of actions/checkout won't have permission to update GHCR.io/actions, |
| 6 | + # so avoid trigger events that run automatically.) |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + publish: |
| 10 | + description: 'Publish to ghcr.io?' |
| 11 | + type: boolean |
| 12 | + required: true |
| 13 | + default: false |
| 14 | + |
| 15 | +env: |
| 16 | + REGISTRY: ghcr.io |
| 17 | + IMAGE_NAME: actions/test-ubuntu-git |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-push-image: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + packages: write |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + # Use `docker/login-action` to log in to GHCR.io. |
| 32 | + # Once published, the packages are scoped to the account defined here. |
| 33 | + - name: Log in to the ghcr.io container registry |
| 34 | + |
| 35 | + with: |
| 36 | + registry: ${{ env.REGISTRY }} |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + # Use `docker/metadata-action` to preserve tags and labels that exist on the GHCR.io container image. |
| 41 | + # - name: Extract metadata (tags, labels) for Docker |
| 42 | + # id: meta |
| 43 | + |
| 44 | + # with: |
| 45 | + # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 46 | + |
| 47 | + # Use `docker/build-push-action` to build (and optionally publish) the image. |
| 48 | + - name: Build and push Docker image |
| 49 | + |
| 50 | + with: |
| 51 | + context: . |
| 52 | + file: images/test-ubuntu-git.Dockerfile |
| 53 | + push: ${{ inputs.publish }} |
| 54 | + tags: ${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA }} |
| 55 | + # tags: ${{ steps.meta.outputs.tags }} |
| 56 | + # labels: ${{ steps.meta.outputs.labels }} |
0 commit comments