-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (89 loc) · 3.18 KB
/
docker-build-latest.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Upload latest to DockerHub
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Install Checkout
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0
- name: Determine Version
id: gitversion # id to later be referenced
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: /config commit-date-format="yyyy-MM-ddTHH:mm:ss-0000"
- name: Alternate Git Version
id: alternategitversion
uses: codacy/[email protected]
with:
release-branch: 'main'
prefix: 'v'
- name: Direct Git Version
id: directgitversion
run: |
GITDIRECTVERSION=`git describe --tags --dirty`
echo "GITDIRECTVERSION=${GITDIRECTVERSION}" >> $GITHUB_ENV
- name: Display GitVersion outputs (step output)
run: |
GITSHA=${{ steps.gitversion.outputs.Sha }}
GITSHA8=${GITSHA:0:8}
GITCOMMITS=${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
GITPREVVERSION=${{ steps.alternategitversion.outputs.previous-version }}
GITVERSION=${GITPREVVERSION}+${GITCOMMITS}.g${GITSHA8}
GITTIME=`git show | grep Date | head -n 1 | awk '{print $5 $7}'`
GITDATE=${{ steps.gitversion.outputs.commitDate }}"T"${GITTIME}
echo "GITVERSION=${GITVERSION}" >> $GITHUB_ENV
echo "GITSHA=${GITSHA}" >> $GITHUB_ENV
echo "GITDATE=${GITDATE}" >> $GITHUB_ENV
BUILD_TIME=$(date -Iseconds)
echo "BUILD_TIME=${BUILD_TIME}" >> $GITHUB_ENV
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get version number
id: get_version
run: echo "VERSION=${{ github.ref }}" >> $GITHUB_OUTPUT
- name: Free disk space
run: |
df -h
sudo rm -rf ${GITHUB_WORKSPACE}/.git
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
sbom: false
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max
tags: fredericklab/capcalc:latest
build-args: |
BRANCH=${{ env.BRANCH }}
GITVERSION=${{ env.GITVERSION }}
GITSHA=${{ env.GITSHA }}
GITDATE=${{ env.GITDATE }}
BUILD_TIME=${{ env.BUILD_TIME }}