Skip to content

Instantly share code, notes, and snippets.

@devantler
Created August 17, 2022 11:36
Show Gist options
  • Save devantler/45956eff0616b7a0398ab488e2060610 to your computer and use it in GitHub Desktop.
Save devantler/45956eff0616b7a0398ab488e2060610 to your computer and use it in GitHub Desktop.
GitHub Action Job to push to GHCR
build-and-push-image:
  needs: [build, test]
  runs-on: ubuntu-latest
  permissions:
    contents: read
    packages: write
  steps:
    - uses: actions/checkout@v2
    - uses: actions/download-artifact@v2
      with:
        name: jar
        path: app/build/libs
    - uses: docker/setup-qemu-action@v2
    - uses: docker/setup-buildx-action@v2
    - uses: docker/metadata-action@v4
      id: meta
      with:
        images: ghcr.io/devantler/06-docker-image
    - uses: docker/login-action@v2
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}
    - uses: docker/build-push-action@v3
      with:
        context: app/
        platforms: linux/amd64
        push: true
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment