Skip to content

Feat/semver (#7)

Feat/semver (#7) #32

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
- 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