-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.33 KB
/
ci.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
name: Continuous Integration
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
env:
GO_VERSION: "1.20"
jobs:
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Build timestamp and branch name
run: |
echo "BUILD_TIMESTAMP=$(date +'%s')" >> $GITHUB_ENV
echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
with:
push: true
build-args: |
VERSION=${{ env.VERSION }}
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
COMMIT_HASH=${{ github.sha }}
tags: |
ghcr.io/${{ github.repository }}:${{ env.VERSION }}
ghcr.io/${{ github.repository }}:${{ github.sha }}