|
| 1 | +name: Bump version and publish to ghcr.io |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +jobs: |
| 8 | + tag: |
| 9 | + name: bump tags |
| 10 | + outputs: |
| 11 | + part: ${{ steps.bump_tag.outputs.part }} |
| 12 | + tag: ${{ steps.bump_tag.outputs.tag }} |
| 13 | + new_tag: ${{ steps.bump_tag.outputs.new_tag }} |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + fetch-depth: '1' |
| 19 | + - name: Bump version and push tag |
| 20 | + id: bump_tag |
| 21 | + uses: anothrNick/github-tag-action@1.36.0 |
| 22 | + env: |
| 23 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + WITH_V: true |
| 25 | + DEFAULT_BUMP: patch |
| 26 | + |
| 27 | + push_to_registry: |
| 28 | + needs: tag |
| 29 | + if: needs.tag.outputs.part != '' |
| 30 | + name: Push Docker image to Github Container registry |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + packages: write |
| 35 | + steps: |
| 36 | + - name: Check out the repo |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Log in to the Github Container registry |
| 40 | + uses: docker/login-action@v1 |
| 41 | + with: |
| 42 | + registry: ghcr.io |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Extract metadata (tags, labels) for Docker |
| 47 | + id: meta |
| 48 | + uses: docker/metadata-action@v3 |
| 49 | + with: |
| 50 | + images: ghcr.io/${{ github.repository }} |
| 51 | + |
| 52 | + - name: Build and push |
| 53 | + uses: docker/build-push-action@v2 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + file: ./Dockerfile |
| 57 | + push: true |
| 58 | + tags: | |
| 59 | + ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }} |
| 60 | + ghcr.io/${{ github.repository }}:latest |
| 61 | + ${{ github.repository }}:${{ needs.tag.outputs.tag }} |
| 62 | + ${{ github.repository }}:latest |
| 63 | + labels: | |
| 64 | + org.opencontainers.image.source=${{ github.event.repository.clone_url }} |
| 65 | + org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 66 | + org.opencontainers.image.revision=${{ github.sha }} |
0 commit comments