|
1 | | -name: Docker |
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 and Push |
7 | 2 |
|
8 | 3 | on: |
9 | 4 | push: |
| 5 | + branches: [main, test] |
10 | 6 | # Publish semver tags as releases. |
11 | | - tags: [ 'v*.*.*' ] |
| 7 | + tags: ["v*.*.*", "v*.*.*.*"] |
12 | 8 |
|
13 | 9 | env: |
14 | | - # Use docker.io for Docker Hub if empty |
15 | 10 | REGISTRY: ghcr.io |
16 | | - # github.repository as <account>/<repo> |
17 | | - IMAGE_NAME: ${{ github.repository }} |
18 | | - |
19 | 11 |
|
20 | 12 | jobs: |
21 | 13 | build: |
22 | | - |
23 | 14 | runs-on: ubuntu-latest |
24 | | - permissions: |
25 | | - contents: read |
26 | | - packages: write |
27 | | - # This is used to complete the identity challenge |
28 | | - # with sigstore/fulcio when running outside of PRs. |
29 | | - id-token: write |
30 | 15 |
|
31 | 16 | steps: |
32 | 17 | - name: Checkout repository |
33 | 18 | uses: actions/checkout@v3 |
34 | 19 |
|
35 | | - # Workaround: https://github.com/docker/build-push-action/issues/461 |
36 | | - - name: Setup Docker buildx |
37 | | - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf |
38 | | - |
39 | | - # Login against a Docker registry except on PR |
40 | | - # https://github.com/docker/login-action |
41 | 20 | - name: Log into registry ${{ env.REGISTRY }} |
42 | | - if: github.event_name != 'pull_request' |
43 | | - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
| 21 | + uses: docker/login-action@v2 |
44 | 22 | with: |
45 | 23 | registry: ${{ env.REGISTRY }} |
46 | 24 | username: ${{ github.actor }} |
47 | 25 | password: ${{ secrets.GITHUB_TOKEN }} |
48 | 26 |
|
49 | | - # Extract metadata (tags, labels) for Docker |
50 | | - # https://github.com/docker/metadata-action |
51 | | - - name: Extract Docker metadata |
52 | | - id: meta |
53 | | - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 27 | + - name: Generate release tag |
| 28 | + id: generate_release_tag |
| 29 | + uses: amitsingh-007/next-release-tag@v4.0.0 |
54 | 30 | with: |
55 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 31 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + tag_prefix: "v" |
| 33 | + tag_template: "yyyy.mm.dd.i" |
56 | 34 |
|
57 | | - # Build and push Docker image with Buildx (don't push on PR) |
58 | | - # https://github.com/docker/build-push-action |
59 | 35 | - name: Build and push Docker image |
60 | | - id: build-and-push |
61 | | - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
| 36 | + uses: docker/build-push-action@v3 |
62 | 37 | with: |
63 | 38 | context: . |
64 | | - push: ${{ github.event_name != 'pull_request' }} |
65 | | - tags: ${{ steps.meta.outputs.tags }} |
66 | | - labels: ${{ steps.meta.outputs.labels }} |
| 39 | + push: true |
| 40 | + tags: ghcr.io/${{ github.repository }}:${{ steps.generate_release_tag.outputs.next_release_tag }} |
| 41 | + |
| 42 | + - name: Create release |
| 43 | + uses: ncipollo/release-action@v1 |
| 44 | + with: |
| 45 | + tag: ${{ steps.generate_release_tag.outputs.next_release_tag }} |
0 commit comments