|
1 | 1 | name: Build and Publish
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - # run it on push to the default repository branch |
5 | 4 | push:
|
6 |
| - branches: [master, develop] |
7 |
| - # run it during pull request |
8 |
| - pull_request: |
9 |
| - # Allows you to run this workflow manually from the Actions tab |
| 5 | + branches: [master, develop, jay/*] |
| 6 | + tags: |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 8 | + - "v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" |
| 9 | + - "[v]?[0-9]+.[0-9]+.[0-9]+(-rc|-alpha|-beta)?[0-9]*" |
10 | 10 | workflow_dispatch:
|
11 | 11 |
|
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + repository-projects: write |
| 15 | + packages: write |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
12 | 21 | env:
|
13 | 22 | REGISTRY: ghcr.io
|
14 | 23 | IMAGE_NAME: ${{ github.repository }}
|
15 | 24 |
|
16 | 25 | jobs:
|
17 |
| - docker: |
18 |
| - name: Build Docker image and push to repositories |
19 |
| - # run only when code is compiling and tests are passing |
| 26 | + publish: |
| 27 | + name: Build and Publish |
20 | 28 | runs-on: ubuntu-latest
|
21 | 29 | permissions:
|
22 |
| - contents: read |
| 30 | + contents: write |
23 | 31 | packages: write
|
24 | 32 |
|
25 | 33 | # steps to perform in job
|
26 | 34 | steps:
|
27 | 35 | - name: Checkout code
|
28 |
| - uses: actions/checkout@v3 |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Set up QEMU |
| 39 | + uses: docker/setup-qemu-action@v3 |
29 | 40 |
|
30 |
| - # setup Docker buld action |
31 | 41 | - name: Set up Docker Buildx
|
32 | 42 | id: buildx
|
33 |
| - uses: docker/setup-buildx-action@v1 |
| 43 | + uses: docker/setup-buildx-action@v3 |
34 | 44 |
|
35 | 45 | - name: Login to Github Packages
|
36 |
| - uses: docker/login-action@v1 |
| 46 | + uses: docker/login-action@v3 |
37 | 47 | with:
|
38 | 48 | registry: ${{ env.REGISTRY }}
|
39 | 49 | username: ${{ github.actor }}
|
40 |
| - password: ${{ github.token }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
41 | 51 |
|
42 | 52 | - name: Extract metadata (tags, labels) for Docker
|
43 | 53 | id: meta
|
44 |
| - uses: docker/metadata-action@v2 |
| 54 | + uses: docker/metadata-action@v5 |
45 | 55 | with:
|
46 | 56 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
47 | 57 |
|
| 58 | + - name: Sanitize GitHub ref name |
| 59 | + id: sanitize |
| 60 | + run: echo "::set-output name=ref_name::$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9_.-]/-/g' | tr '[:upper:]' '[:lower:]')" |
| 61 | + |
| 62 | + - name: Sanitize repository name |
| 63 | + id: sanitize_repo |
| 64 | + run: echo "::set-output name=repo_name::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" |
| 65 | + |
48 | 66 | - name: Build image and push to GitHub Container Registry
|
49 |
| - uses: docker/build-push-action@v4 |
| 67 | + uses: docker/build-push-action@v5 |
50 | 68 | with:
|
51 |
| - # Note: tags has to be all lower-case |
52 |
| - tags: ${{ steps.meta.outputs.tags }} |
53 |
| - # build on feature branches, push only on master |
| 69 | + labels: ${{ steps.meta.outputs.labels }} |
| 70 | + tags: | |
| 71 | + ${{ env.REGISTRY }}/${{ steps.sanitize_repo.outputs.repo_name }}:${{ steps.sanitize.outputs.ref_name }} |
| 72 | + ${{ env.REGISTRY }}/${{ steps.sanitize_repo.outputs.repo_name }}:latest |
54 | 73 | push: true
|
| 74 | + cache-from: type=gha |
| 75 | + cache-to: type=gha,mode=max |
| 76 | + outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.sanitize_repo.outputs.repo_name }},name-canonical=true,push=true |
55 | 77 |
|
56 | 78 | - name: Image digest
|
57 | 79 | run: echo ${{ steps.docker_build.outputs.digest }}
|
| 80 | + |
| 81 | + - name: Create GitHub Release |
| 82 | + uses: ncipollo/release-action@v1 |
| 83 | + with: |
| 84 | + allowUpdates: true |
| 85 | + generateReleaseNotes: true |
| 86 | + body: ${{ steps.changelog.outputs.clean_changelog }} |
| 87 | + artifacts: "" |
0 commit comments