-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.22 KB
/
build.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
name: Build
on: [push, pull_request]
env:
GITHUB_SHA: ${{ github.sha }}
IMAGE: shelman/run-with-secrets
REGISTRY_HOSTNAME: quay.io
REGISTRY_USERNAME: shelman+githubbot
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
jobs:
build:
name: Build ${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build
run: go build -v .
- name: Build docker image
run: |
docker build \
--label "github/commit-ref=${{ github.ref }}" \
--label "github/commit-sha=${{ github.sha }}" \
--label "github/repository=${{ github.repository }}" \
-t "$REGISTRY_HOSTNAME"/"$IMAGE":"$GITHUB_SHA" .
- name: Publish docker image
if: github.ref == 'refs/heads/master'
run: |
docker login -u "$REGISTRY_USERNAME" -p "$REGISTRY_PASSWORD" "$REGISTRY_HOSTNAME"
docker push $REGISTRY_HOSTNAME/$IMAGE:$GITHUB_SHA
docker tag $REGISTRY_HOSTNAME/$IMAGE:$GITHUB_SHA $REGISTRY_HOSTNAME/$IMAGE:latest
docker push $REGISTRY_HOSTNAME/$IMAGE:latest