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: Build and Push Docker Image to GitHub Packages | |
on: | |
push: | |
branches: | |
- main | |
- 'v*.*.*' | |
workflow_dispatch: | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: heavybullets8 | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Extract version | |
id: vars | |
run: | | |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then | |
VERSION=${GITHUB_REF_NAME#refs/tags/v} | |
else | |
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") | |
fi | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/heavybullets8/zfs-scrubber:latest | |
ghcr.io/heavybullets8/zfs-scrubber:${{ env.VERSION }} |