Skip to content

Instantly share code, notes, and snippets.

@dazz
Last active December 1, 2022 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dazz/8c9215fa6e03ead8ae065fae1106c82e to your computer and use it in GitHub Desktop.
Save dazz/8c9215fa6e03ead8ae065fae1106c82e to your computer and use it in GitHub Desktop.
medium_github-actions-push-ghcr
name: Continuous Delivery
on:
push:
branches:
- 'main'
tags:
- 'v*.*.*'
jobs:
build:
name: Buid and push Docker image to GitHub Container registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v2.2.1
- name: Docker Login
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v3.2.0
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
with:
context: .
file: ./Dockerfile
target: final
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment