|
14 | 14 | tags: [ 'v*.*.*' ] |
15 | 15 | pull_request: |
16 | 16 | branches: [ main ] |
17 | | - |
18 | | -env: |
19 | | - # Use docker.io for Docker Hub if empty |
20 | | - REGISTRY: docker.io |
21 | | - # github.repository as <account>/<repo> |
22 | | - IMAGE_NAME: tofandel/php_node |
23 | | - |
24 | | - |
25 | 17 | jobs: |
| 18 | + |
26 | 19 | build: |
27 | 20 |
|
28 | 21 | runs-on: ubuntu-latest |
29 | | - permissions: |
30 | | - contents: read |
31 | | - packages: write |
32 | | - # This is used to complete the identity challenge |
33 | | - # with sigstore/fulcio when running outside of PRs. |
34 | | - id-token: write |
35 | 22 |
|
36 | 23 | steps: |
37 | | - - name: Checkout repository |
38 | | - uses: actions/checkout@v3 |
39 | | - |
40 | | - # Install the cosign tool except on PR |
41 | | - # https://github.com/sigstore/cosign-installer |
42 | | - - name: Install cosign |
43 | | - if: github.event_name != 'pull_request' |
44 | | - |
| 24 | + - name: Publish Docker |
| 25 | + # You may pin to the exact commit or the version. |
| 26 | + # uses: elgohr/Publish-Docker-Github-Action@93655185f260b851ede78d9a57760a8bbda65f68 |
| 27 | + uses: elgohr/Publish-Docker-Github-Action@v4 |
45 | 28 | with: |
46 | | - cosign-release: 'v1.4.0' |
47 | | - |
48 | | - |
49 | | - # Workaround: https://github.com/docker/build-push-action/issues/461 |
50 | | - - name: Setup Docker buildx |
51 | | - uses: docker/setup-buildx-action@v1 |
52 | | - |
53 | | - # Login against a Docker registry except on PR |
54 | | - # https://github.com/docker/login-action |
55 | | - - name: Log into registry ${{ env.REGISTRY }} |
56 | | - if: github.event_name != 'pull_request' |
57 | | - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
58 | | - with: |
59 | | - registry: ${{ env.REGISTRY }} |
| 29 | + # The name of the image you would like to push |
| 30 | + name: tofandel/php_node |
| 31 | + # The login username for the registry |
60 | 32 | username: ${{ secrets.DOCKER_USERNAME }} |
61 | | - password: ${{ secrets.DOCKER_TOKEN }} |
62 | | - |
63 | | - # Extract metadata (tags, labels) for Docker |
64 | | - # https://github.com/docker/metadata-action |
65 | | - - name: Extract Docker metadata |
66 | | - id: meta |
67 | | - uses: docker/metadata-action@v3 |
68 | | - with: |
69 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
70 | | - |
71 | | - - name: Cache Docker layers |
72 | | - uses: actions/cache@v3 |
73 | | - with: |
74 | | - path: /tmp/.buildx-cache |
75 | | - key: ${{ runner.os }}-single-buildx-${{ github.sha }} |
76 | | - restore-keys: | |
77 | | - ${{ runner.os }}-single-buildx |
78 | | - |
79 | | - # Build and push Docker image with Buildx (don't push on PR) |
80 | | - # https://github.com/docker/build-push-action |
81 | | - - name: Build and push Docker image |
82 | | - id: build-and-push |
83 | | - uses: docker/build-push-action@v2 |
84 | | - with: |
85 | | - context: . |
86 | | - push: ${{ github.event_name != 'pull_request' }} |
87 | | - tags: ${{ steps.meta.outputs.tags }} |
88 | | - labels: ${{ steps.meta.outputs.labels }} |
89 | | - cache-from: type=local,src=/tmp/.buildx-cache |
90 | | - cache-to: type=local,dest=/tmp/.buildx-cache-new |
91 | | - |
92 | | - # Temp fix |
93 | | - # https://github.com/docker/build-push-action/issues/252 |
94 | | - # https://github.com/moby/buildkit/issues/1896 |
95 | | - - name: Move cache |
96 | | - run: |
97 | | - rm -rf /tmp/.buildx-cache |
98 | | - mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
99 | | - |
100 | | - # Sign the resulting Docker image digest except on PRs. |
101 | | - # This will only write to the public Rekor transparency log when the Docker |
102 | | - # repository is public to avoid leaking data. If you would like to publish |
103 | | - # transparency data even for private images, pass --force to cosign below. |
104 | | - # https://github.com/sigstore/cosign |
105 | | - - name: Sign the published Docker image |
106 | | - if: ${{ github.event_name != 'pull_request' }} |
107 | | - env: |
108 | | - COSIGN_EXPERIMENTAL: "true" |
109 | | - # This step uses the identity token to provision an ephemeral certificate |
110 | | - # against the sigstore community Fulcio instance. |
111 | | - run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} |
| 33 | + # The login password for the registry |
| 34 | + password: ${{ secrets.DOCKER_PASSWORD |
| 35 | + tag_semver: true |
0 commit comments