Last active
December 1, 2022 22:57
-
-
Save dazz/8c9215fa6e03ead8ae065fae1106c82e to your computer and use it in GitHub Desktop.
medium_github-actions-push-ghcr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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