Skip to content

Instantly share code, notes, and snippets.

@dazz
Last active December 1, 2022 22:57
Show Gist options
  • 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/[email protected]
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/[email protected]
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