-
Notifications
You must be signed in to change notification settings - Fork 4
66 lines (56 loc) · 1.84 KB
/
build-and-push-docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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