-
-
Notifications
You must be signed in to change notification settings - Fork 251
101 lines (87 loc) · 2.78 KB
/
pr-snapshot.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
93
94
95
96
97
98
99
100
101
name: Build snapshot of PR
on: pull_request
env:
REGISTRY_IMAGE: ghcr.io/museofficial/muse
jobs:
build:
name: Build snapshot
strategy:
matrix:
runner-platform:
- ubuntu-latest
- namespace-profile-default-arm64
include:
- runner-platform: ubuntu-latest
build-arch: linux/amd64
- runner-platform: namespace-profile-default-arm64
build-arch: linux/arm64
runs-on: ${{ matrix.runner-platform }}
steps:
- name: Prepare
run: |
platform=${{ matrix.build-arch }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: type=ref,event=pr
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
- name: Build
id: build
uses: docker/build-push-action@v6
with:
outputs: type=docker,dest=/tmp/image-${{ env.PLATFORM_PAIR }}.tar
platforms: ${{ matrix.build-arch }}
tags: |
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ env.PLATFORM_PAIR }}
build-args: |
COMMIT_HASH=${{ github.sha }}
BUILD_DATE=${{ steps.current-time.outputs.time }}
- name: Export Docker meta output
shell: bash
run: echo $DOCKER_METADATA_OUTPUT_JSON > /tmp/metadata.json
- name: Upload metadata
uses: actions/upload-artifact@v4
with:
name: metadata
path: /tmp/metadata.json
overwrite: true
- name: Export SHA
run: |
echo "${{ github.sha }}" > /tmp/sha.txt
- name: Upload SHA
uses: actions/upload-artifact@v4
with:
name: sha
path: /tmp/sha.txt
overwrite: true
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: image-${{ env.PLATFORM_PAIR }}
path: /tmp/image-${{ env.PLATFORM_PAIR }}.tar
if-no-files-found: error
retention-days: 1
- name: Save PR number in artifact
shell: bash
env:
PR_NUMBER: ${{ github.event.number }}
run: echo $PR_NUMBER > /tmp/pull_request_number.txt
- name: Upload PR number
uses: actions/upload-artifact@v4
with:
name: pull_request_number
path: /tmp/pull_request_number.txt
overwrite: true