This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
63 lines (58 loc) · 2.04 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build
on: [ push, pull_request ]
jobs:
workflow-setup:
runs-on: ubuntu-latest
outputs:
CACHE_KEY_IMAGE: ${{ steps.cache.outputs.CACHE_KEY_IMAGE }}
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Set outputs
id: cache
run: |
echo "::set-output name=CACHE_KEY_IMAGE::${{ hashFiles('.github/workflows/Dockerfile') }}"
build-image:
needs: workflow-setup
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
CACHE_KEY_IMAGE: ${{ needs.workflow-setup.outputs.CACHE_KEY_IMAGE }}
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Try load from cache.
id: cache-image
uses: actions/cache@v2
with:
path: ${GITHUB_WORKSPACE}/cache
key: ${{ env.CACHE_KEY_IMAGE}}
- name: If NOT found in cache, build and push image.
if: steps.cache-image.outputs.cache-hit != 'true'
run: |
echo ${{ secrets.CR_PAT }} | docker login ghcr.io --username ${{ secrets.CR_USER }} --password-stdin
docker build -f .github/workflows/Dockerfile --no-cache -t ${GITHUB_REPOSITORY}/uwg-build:${{ env.CACHE_KEY_IMAGE }} .
docker tag ${GITHUB_REPOSITORY}/uwg-build:${{ env.CACHE_KEY_IMAGE }} ghcr.io/${GITHUB_REPOSITORY}/uwg-build:latest
docker push ghcr.io/${GITHUB_REPOSITORY}/uwg-build:latest
mkdir -p ${GITHUB_WORKSPACE}/cache
touch ${GITHUB_WORKSPACE}/cache/${{ env.CACHE_KEY_IMAGE }}
test:
name: Test using Ursa
needs: build-image
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}/uwg-build
strategy:
matrix:
go-version: [1.14, 1.15]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Test using Ursa ${{ matrix.ursa-version }}
run: |
make test