Skip to content

Commit 396d027

Browse files
authored
Add go-cache and trigger Docker release from published Release (#59)
1 parent 040f727 commit 396d027

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

.github/workflows/ci.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
name: "CI"
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- "master"
6+
pull_request:
37

48
jobs:
59
basic-checks:
610
runs-on: ubuntu-latest
711
steps:
812
- uses: actions/checkout@v3
13+
914
- uses: actions/setup-go@v3
1015
with:
1116
go-version: "1.17"
1217

18+
- name: Cache Go modules
19+
uses: actions/cache@v1
20+
with:
21+
path: ~/go/pkg/mod
22+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
${{ runner.os }}-go-
25+
1326
- name: "Formatting check"
1427
run: make fmt
1528

.github/workflows/release.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
name: "Release"
22
on:
3-
push:
4-
tags:
5-
- "v*"
3+
release:
4+
types: [published]
65

76
jobs:
87
docker:
98
runs-on: ubuntu-latest
9+
if: github.event.release.target_commitish == 'master'
1010
steps:
1111
- uses: actions/checkout@v3
12+
1213
- uses: actions/setup-go@v3
1314
with:
14-
go-version: "1.17"
15+
go-version: "1.17.7"
1516

1617
- name: Set tag in environment
1718
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV # extracts the tag name from refs/tags/v1.2.3
@@ -21,9 +22,9 @@ jobs:
2122

2223
- name: "Docker login to Quay.io"
2324
env:
24-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
25-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
26-
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD quay.io
25+
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
26+
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
27+
run: docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
2728

2829
- name: "Push image"
2930
run: make docker-push TAG=$RELEASE_VERSION

0 commit comments

Comments
 (0)