diff --git a/.github/workflows/ghrc-publish.yml b/.github/workflows/ghrc-publish.yml new file mode 100644 index 0000000..5204706 --- /dev/null +++ b/.github/workflows/ghrc-publish.yml @@ -0,0 +1,84 @@ +name: GHCR Publish + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + workflow_dispatch: + push: + branches: [ "**" ] + # Publish semver tags as releases. + tags: [ 'v*' ] + #schedule: + # - cron: '30 15 * * *' + #pull_request: + # branches: [ main ] + +env: + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + REGISTRY: "ghcr.io" + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # # Install the cosign tool except on PR + # # https://github.com/sigstore/cosign-installer + # - name: Install cosign + # if: github.event_name != 'pull_request' + # uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422 + # with: + # cosign-release: 'v1.4.0' + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + "type=raw,value={{date 'X'}}_{{tag}}{{branch}}_{{sha}}" + "type=raw,value=latest" + "type=ref,event=tag" + "type=semver,pattern=v{{major}}" + "type=ref,event=branch" + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v3 + with: + #context: "{{defaultContext}}:jiracmdline" + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}