|
1 | | -name: Build and publish |
2 | | - |
3 | | -# This workflow uses actions that are not certified by GitHub. |
4 | | -# They are provided by a third-party and are governed by |
5 | | -# separate terms of service, privacy policy, and support |
6 | | -# documentation. |
| 1 | +name: Build Docker Image |
7 | 2 |
|
8 | 3 | on: |
9 | | - # schedule: |
10 | | - # - cron: '21 16 * * *' |
11 | 4 | push: |
12 | | - branches: ["main"] |
13 | | - # Publish semver tags as releases. |
14 | | - tags: ["v*.*.*"] |
15 | | - pull_request: |
16 | | - branches: ["main"] |
17 | | - |
18 | | -env: |
19 | | - # Use docker.io for Docker Hub if empty |
20 | | - REGISTRY: ghcr.io |
21 | | - # github.repository as <account>/<repo> |
22 | | - IMAGE_NAME: ${{ github.repository }} |
23 | 5 |
|
24 | 6 | jobs: |
25 | | - build: |
| 7 | + docker: |
26 | 8 | runs-on: ubuntu-latest |
27 | 9 | permissions: |
28 | | - contents: read |
29 | 10 | packages: write |
30 | | - # This is used to complete the identity challenge |
31 | | - # with sigstore/fulcio when running outside of PRs. |
32 | | - id-token: write |
33 | | - |
34 | 11 | steps: |
35 | | - - name: Checkout repository |
36 | | - uses: actions/checkout@v4 |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v5 |
37 | 14 |
|
38 | | - # Install the cosign tool except on PR |
39 | | - # sigstore/cosign-installer |
40 | | - # - name: Install cosign |
41 | | - # if: github.event_name != 'pull_request' |
42 | | - # uses: sigstore/cosign-installer@d6a3abf1bdea83574e28d40543793018b6035605 |
43 | | - # with: |
44 | | - # cosign-release: 'v1.7.1' |
45 | | - |
46 | | - # Workaround: docker/build-push-action/issues/461 |
47 | | - - name: Setup Docker buildx |
48 | | - uses: docker/setup-buildx-action@v3 |
49 | | - with: |
50 | | - driver: docker |
| 15 | + - name: Variables |
| 16 | + id: vars |
| 17 | + run: | |
| 18 | + echo "sha_long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 19 | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
51 | 20 |
|
52 | | - # Login against a Docker registry except on PR |
53 | | - # docker/login-action |
54 | | - - name: Log into registry ${{ env.REGISTRY }} |
55 | | - if: github.event_name != 'pull_request' |
| 21 | + - name: Login to Docker Hub |
56 | 22 | uses: docker/login-action@v3 |
57 | 23 | with: |
58 | | - registry: ${{ env.REGISTRY }} |
| 24 | + registry: https://ghcr.io |
59 | 25 | username: ${{ github.actor }} |
60 | 26 | password: ${{ secrets.GITHUB_TOKEN }} |
61 | 27 |
|
62 | | - # Extract metadata (tags, labels) for Docker |
63 | | - # docker/metadata-action |
64 | | - - name: Extract Docker metadata |
65 | | - id: meta |
66 | | - uses: docker/metadata-action@v5 |
67 | | - with: |
68 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 28 | + - name: Set up QEMU |
| 29 | + uses: docker/setup-qemu-action@v3 |
69 | 30 |
|
70 | | - # Build and push Docker image with Buildx (don't push on PR) |
71 | | - # docker/build-push-action |
72 | | - - name: Build and push Docker image |
73 | | - id: build-and-push |
| 31 | + - name: Set up Docker Buildx |
| 32 | + uses: docker/setup-buildx-action@v3 |
| 33 | + |
| 34 | + - name: Build and push |
74 | 35 | uses: docker/build-push-action@v6 |
75 | 36 | with: |
76 | | - context: . |
77 | | - push: ${{ github.event_name != 'pull_request' }} |
78 | | - tags: ${{ steps.meta.outputs.tags }} |
79 | | - labels: ${{ steps.meta.outputs.labels }} |
80 | | - # cache-from: type=gha |
81 | | - # cache-to: type=gha,mode=max |
82 | | - |
83 | | - # Sign the resulting Docker image digest except on PRs. |
84 | | - # This will only write to the public Rekor transparency log when the Docker |
85 | | - # repository is public to avoid leaking data. If you would like to publish |
86 | | - # transparency data even for private images, pass --force to cosign below. |
87 | | - # sigstore/cosign |
88 | | - # - name: Sign the published Docker image |
89 | | - # if: ${{ github.event_name != 'pull_request' }} |
90 | | - # env: |
91 | | - # COSIGN_EXPERIMENTAL: "true" |
92 | | - # This step uses the identity token to provision an ephemeral certificate |
93 | | - # against the sigstore community Fulcio instance. |
94 | | - # run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }} |
| 37 | + push: true |
| 38 | + tags: | |
| 39 | + ghcr.io/scouterna/j26-auth:latest |
| 40 | + ghcr.io/scouterna/j26-auth:${{ steps.vars.outputs.sha_short }} |
| 41 | + labels: | |
| 42 | + org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} |
| 43 | + org.opencontainers.image.revision=${{ steps.vars.outputs.sha_long }} |
| 44 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 45 | + org.opencontainers.image.description=Jamboree26 Authentication Service |
| 46 | + org.opencontainers.image.licenses=MIT |
0 commit comments