-
Notifications
You must be signed in to change notification settings - Fork 20
92 lines (83 loc) · 3.39 KB
/
runtime-builder-image.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
82
83
84
85
86
87
88
89
90
91
92
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: runtime-builder-image
on:
push:
# XXX: ideally on main branches we would build the image only if there are changes in the
# 'docker/' directory (as we do in pull_requests). However, this doesn't work when pushing a new
# 'stable/*' branch - the build on a new branch does not trigger unless there are changes
# compared to main on the filtered path.
# If this is ever fixed, or per branch filters are possible, bring back the path filter to only
# build the image when there are changes within 'docker/' directory.
branches:
- main
- stable/*
# Or when a pull request event occurs for a pull request against one of the matched branches and at least
# one modified file matches the configured paths.
#
# NOTE: We use this to be able to easily test Docker image changes.
pull_request:
branches:
- main
- stable/*
paths:
- docker/runtime-builder/**
# Or every day at 04:00 UTC (for the default/main branch).
schedule:
- cron: "0 4 * * *"
# Cancel in-progress jobs on same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-runtime-builder:
# NOTE: This name appears in GitHub's Checks API.
name: build-runtime-builder
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Check out pull request's HEAD commit instead of the merge commit.
ref: ${{ github.event.pull_request.head.sha }}
- name: Determine tag name
id: determine-tag
uses: ./.github/actions/determine-tag
- name: Determine Oasis Core Commit Ref
id: determine-oasis-core-commit-ref
uses: ./.github/actions/oasis-core-commit-ref
- name: Determine Rust Toolchain version
id: determine-rust-version
uses: ./.github/actions/rust-version
- 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: "Rebuild oasisprotocol/runtime-builder:${{ steps.determine-tag.outputs.tag }}"
uses: docker/build-push-action@v5
with:
context: docker/runtime-builder
file: docker/runtime-builder/Dockerfile
tags: ghcr.io/oasisprotocol/runtime-builder:${{ steps.determine-tag.outputs.tag }}
pull: true
push: true
build-args: |
OASIS_CORE_COMMIT=${{ steps.determine-oasis-core-commit-ref.outputs.ref }}
RUST_NIGHTLY_VERSION=${{ steps.determine-rust-version.outputs.version }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.determine-tag.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Prune old ghcr.io/oasisprotocol/runtime-builder images
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: oasisprotocol
container: runtime-builder
keep-younger-than: 7 # days
keep-last: 2
prune-untagged: true
prune-tags-regexes: ^pr-