-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.42 KB
/
docker.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
name: Docker Image CI
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true
release:
types: [created]
jobs:
build-and-push:
runs-on: github-hosted-heavy-runner
steps:
- name: Log in to Docker registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Determine tags
run: |
REPO_NAME="${GITHUB_REPOSITORY#*/}"
DOCKERHUB_REPO="${{ secrets.DOCKERHUB_USERNAME }}/$REPO_NAME"
RELEASE_TAG="${{ github.event.release.tag_name }}"
INPUT_TAG="${{ github.event.inputs.tag }}"
if [[ "$RELEASE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "TAGS=$DOCKERHUB_REPO:testnet,$DOCKERHUB_REPO:latest,$DOCKERHUB_REPO:$RELEASE_TAG" >> $GITHUB_ENV
else
echo "TAGS=$DOCKERHUB_REPO:testnet,$DOCKERHUB_REPO:${RELEASE_TAG:-$INPUT_TAG}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build app
run: CGO_ENABLED=0 go build -o app .
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.TAGS }}