-
Notifications
You must be signed in to change notification settings - Fork 6
58 lines (49 loc) · 1.74 KB
/
build-push-staging.yml
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
name: "build & push docker staging"
on:
pull_request_target:
branches: [main]
types:
- closed
jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup golang environment
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Install dependencies
run: go mod tidy
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_ENDPOINT }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: set build env variables
shell: bash
run: |
REPO_VERSION=$(git rev-parse --git-dir > /dev/null 2>&1 && git fetch -q origin --tags && git describe --always --dirty --tags)
REPO_REV=$(git rev-parse --git-dir > /dev/null 2>&1 && git rev-parse HEAD 2>/dev/null)
BUILD_DATE=$(date -u +%FT%T)
echo "REPO_VERSION=$REPO_VERSION" >> $GITHUB_ENV
echo "REPO_REV=$REPO_REV" >> $GITHUB_ENV
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ env.REPO_VERSION }}
REPO_REV=${{ env.REPO_REV }}
DATE=${{ env.BUILD_DATE }}
tags: ${{ secrets.DOCKER_ENDPOINT }}${{ secrets.DOCKER_REPO }}/fishymetrics:${{ env.REPO_VERSION }}