-
Notifications
You must be signed in to change notification settings - Fork 8
83 lines (74 loc) · 3.07 KB
/
handle_llvm_runner_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
name: Handle LLVM_runner docker image
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
check_changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
image_to_build: ${{ steps.set_output.outputs.image_to_build }}
steps:
- uses: actions/checkout@v4
- id: determine_changes
uses: tj-actions/changed-files@v39
with:
files_yaml: |
llvm_runner:
- "images/llvm_runner/Dockerfile"
llvm_runner_jammy:
- "images/llvm_runner/jammy.Dockerfile"
both:
- ".github/workflows/handle_llvm_runner_image.yml"
- id: set_output
run: |
if [ "${{ steps.determine_changes.outputs.llvm_runner_any_changed }}" == "true" ]; then
echo "image_to_build=llvm_runner" >> "$GITHUB_OUTPUT"
elif [ "${{ steps.determine_changes.outputs.llvm_runner_jammy_any_changed }}" == "true" ]; then
echo "image_to_build=llvm_runner_jammy" >> "$GITHUB_OUTPUT"
elif [ "${{ steps.determine_changes.outputs.both_any_changed }}" == "true" ]; then
echo "image_to_build=both" >> "$GITHUB_OUTPUT"
else
echo "image_to_build=none" >> "$GITHUB_OUTPUT"
fi
handle_image:
needs: check_changes
if: needs.check_changes.outputs.image_to_build != 'none'
runs-on: [matterlabs-ci-runner]
strategy:
matrix:
image_name: [llvm_runner, llvm_runner_jammy]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set outputs
if: matrix.image_name == needs.check_changes.outputs.image_to_build || needs.check_changes.outputs.image_to_build == 'both'
id: set_output
run: echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
if: matrix.image_name == 'llvm_runner_jammy'
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm64/v8
- name: Log in to Docker Hub
if: (matrix.image_name == needs.check_changes.outputs.image_to_build || needs.check_changes.outputs.image_to_build == 'both') && github.event_name == 'push'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and optionally push Docker image
if: matrix.image_name == needs.check_changes.outputs.image_to_build || needs.check_changes.outputs.image_to_build == 'both'
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'push' }}
tags: |
matterlabs/${{ matrix.image_name }}:${{ steps.set_output.outputs.sha_short }}
matterlabs/${{ matrix.image_name }}:latest
file: images/llvm_runner/${{ matrix.image_name == 'llvm_runner_jammy' && 'jammy.' || '' }}Dockerfile
platforms: ${{ matrix.image_name == 'llvm_runner_jammy' && 'linux/amd64,linux/arm64,linux/arm64/v8' || 'linux/amd64' }}