Skip to content

Feat/UI additions (#12) #48

Feat/UI additions (#12)

Feat/UI additions (#12) #48

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
- name: πŸ“ Get version
run: |
echo "VERSION=$(cat version.yaml | sed -n 's/version: //p')" >> $GITHUB_ENV
echo $VERSION
# Set build tags based on branch
- 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
# Login to GitHub Container Registry
- name: πŸ” Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
# Login to Docker Hub
- name: πŸ” Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: πŸ“¦ Build and Push Image to GHCR (PR)
if: github.event_name == 'pull_request'
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
- name: πŸ“¦ Build and Push Image to GHCR and Docker Hub (Main)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/kek-sec/gopherdrop:${{ env.IMAGE_TAGS }}
petrakisg/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