Fix: version in build workflow #33
Workflow file for this run
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 Images | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-backend: | |
name: π οΈ Build and Push | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Checkout Code | |
uses: actions/checkout@v4 | |
#get version from version.yaml | |
#if on main tag should be the semver from version.yaml | |
#if on PR tag should be rc-semver-PR_NUMBER | |
- name: π Get version | |
run: | | |
echo "VERSION=$(cat version.yaml | shyaml get-value version)" >> $GITHUB_ENV | |
#print the version | |
echo $VERSION | |
- name: ποΈ Set Build tags | |
run: | | |
if [ $GITHUB_REF = 'refs/heads/main' ]; then | |
echo "IMAGE_TAGS=$VERSION" >> $GITHUB_ENV | |
else | |
echo "IMAGE_TAGS=rc-$VERSION-$GITHUB_RUN_NUMBER" >> $GITHUB_ENV | |
fi | |
- name: π οΈ Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: π Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.TOKEN }} | |
- name: π¦ Build and Push Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
ghcr.io/kek-sec/gopherdrop:${{ env.IMAGE_TAGS }} | |
annotations: | | |
org.opencontainers.image.description=GopherDrop, a secure one-time secret sharing service | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
labels: | | |
org.opencontainers.image.source=https://github.com/kek-sec/gopherdrop | |
cache-from: type=registry,ref=ghcr.io/kek-sec/gopherdrop:latest | |
cache-to: type=registry,ref=ghcr.io/kek-sec/gopherdrop:latest |