Skip to content

Instantly share code, notes, and snippets.

@Potherca
Created May 20, 2021 10:45
Show Gist options
  • Save Potherca/ff3ba472a999790f64b3f1ae4e2499b8 to your computer and use it in GitHub Desktop.
Save Potherca/ff3ba472a999790f64b3f1ae4e2499b8 to your computer and use it in GitHub Desktop.
Example of GitHub Action to build and push Docker images to GitHub Registry
name: Build and publish development Docker image
on:
push:
tags:
- 'v*.*.*'
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# @CHECKME: OR use this? run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF#refs/*/})
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/OWNER/IMAGE_NAME:latest
ghcr.io/OWNER/IMAGE_NAME:${{ env.RELEASE_VERSION }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment