-
Notifications
You must be signed in to change notification settings - Fork 15
81 lines (72 loc) · 2.37 KB
/
docker-dev.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
name: docker-dev
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
docker:
strategy:
matrix:
docker_image: [emerald-dev, sapphire-dev]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# We need history to determine oasis-web3-gateway version from git tag.
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute version
# Version docker image by date and git revision.
run: |
echo "VERSION=$(date +%Y-%m-%d-git$(git rev-parse --short HEAD))" >> $GITHUB_ENV
- name: Build
uses: docker/build-push-action@v5
with:
build-args: |
VERSION=${{ env.VERSION }}
context: .
file: docker/${{ matrix.docker_image }}/Dockerfile
tags: |
ghcr.io/oasisprotocol/${{ matrix.docker_image }}:local
load: true
- name: Test
timeout-minutes: 2
working-directory: docker/${{ matrix.docker_image }}
run: ./test.sh
- name: Push
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v5
with:
build-args: |
VERSION=${{ env.VERSION }}
context: .
file: docker/${{ matrix.docker_image }}/Dockerfile
tags: |
ghcr.io/oasisprotocol/${{ matrix.docker_image }}:latest
ghcr.io/oasisprotocol/${{ matrix.docker_image }}:latest-${{ env.VERSION }}
push: true
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Prune old ghcr.io/oasisprotocol/${{ matrix.docker_image }} images
if: ${{ github.event_name == 'push' }}
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: oasisprotocol
container: ${{ matrix.docker_image }}
keep-younger-than: 7 # days
keep-last: 2
prune-untagged: true
prune-tags-regexes: ^latest-