|
| 1 | +name: Build and publish |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '23 2 * * *' |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +env: |
| 15 | + # Use docker.io for Docker Hub if empty |
| 16 | + REGISTRY: harbor.obeone.cloud |
| 17 | + # github.repository as <account>/<repo> |
| 18 | + IMAGE_NAME: public/docker-nfs-server |
| 19 | + |
| 20 | +jobs: |
| 21 | + Build: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + packages: write |
| 26 | + # This is used to complete the identity challenge |
| 27 | + # with sigstore/fulcio when running outside of PRs. |
| 28 | + id-token: write |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v3 |
| 33 | + |
| 34 | + # # Install the cosign tool except on PR |
| 35 | + # # https://github.com/sigstore/cosign-installer |
| 36 | + # - name: Install cosign |
| 37 | + # if: github.event_name != 'pull_request' |
| 38 | + # uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 |
| 39 | + # with: |
| 40 | + # cosign-release: 'v1.9.0' |
| 41 | + |
| 42 | + |
| 43 | + # Workaround: https://github.com/docker/build-push-action/issues/461 |
| 44 | + # - name: Setup Docker buildx |
| 45 | + # uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf |
| 46 | + |
| 47 | + - name: Set up QEMU |
| 48 | + uses: docker/setup-qemu-action@v2 |
| 49 | + - name: Set up Docker Buildx |
| 50 | + uses: docker/setup-buildx-action@v2 |
| 51 | + |
| 52 | + # Login against a Docker registry except on PR |
| 53 | + # https://github.com/docker/login-action |
| 54 | + - name: Log into registry ${{ env.REGISTRY }} |
| 55 | + if: github.event_name != 'pull_request' |
| 56 | + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
| 57 | + with: |
| 58 | + registry: ${{ env.REGISTRY }} |
| 59 | + username: ${{ secrets.REGISTRY_USER }} |
| 60 | + password: ${{ secrets.REGISTRY_PW }} |
| 61 | + |
| 62 | + - name: Build image |
| 63 | + id: build |
| 64 | + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
| 65 | + with: |
| 66 | + context: . |
| 67 | + pull: true |
| 68 | + load: true |
| 69 | + tags: docker-nfs-server:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 70 | + cache-to: type=gha,mode=max |
| 71 | + cache-from: type=gha,mode=max |
| 72 | + |
| 73 | + - name: Finding latest release |
| 74 | + id: version |
| 75 | + uses: pozetroninc/github-action-get-latest-release@master |
| 76 | + with: |
| 77 | + repository: ${{ github.repository }} |
| 78 | + |
| 79 | + |
| 80 | + - name: Parse semver string |
| 81 | + id: semver_parser |
| 82 | + uses: booxmedialtd/ws-action-parse-semver@v1 |
| 83 | + with: |
| 84 | + input_string: "${{ steps.version.outputs.release }}" |
| 85 | + |
| 86 | + |
| 87 | + - name: Publish image |
| 88 | + id: push |
| 89 | + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
| 90 | + with: |
| 91 | + context: . |
| 92 | + push: true |
| 93 | + pull: true |
| 94 | + cache-to: type=gha,mode=max |
| 95 | + cache-from: type=gha,mode=max |
| 96 | + tags: | |
| 97 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.semver_parser.outputs.major }} |
| 98 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }} |
| 99 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} |
| 100 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.semver_parser.outputs.major }} |
| 101 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }} |
| 102 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} |
| 103 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
0 commit comments