GHCR Publish Docker image #6
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: GHCR Publish Docker image | |
on: | |
#push: | |
workflow_dispatch: | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
- '.gitignore' | |
- 'examples/**' | |
- 'docker-compose.yml' | |
- 'Firmware/Configuration/**.h' | |
- '.github/workflows/github-action.yml' | |
schedule: | |
- cron: 0 0 1 * * # First day of month | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
push_to_registry: | |
name: Push Docker image to GitHub Packages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Preparation | |
id: prep | |
run: | | |
REGISTRY="ghcr.io" | |
IMAGE="${REGISTRY}/${{ github.repository }}/${{ github.event.repository.name }}" | |
TAGS="${IMAGE}:${{ github.sha }}" | |
if [[ $GITHUB_REF == ref/head/master ]]; then | |
TAGS="${TAGS},${IMAGE}:latest" | |
fi | |
echo ::set-output name=tags::${TAGS} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: false | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.repository.name }} | |
- uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |