-
Notifications
You must be signed in to change notification settings - Fork 3
94 lines (75 loc) · 3.33 KB
/
stagex.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
name: stagex-build
on:
push:
tags:
- v*.*.*
branches:
- main
pull_request:
workflow_dispatch: # Allows manual invocation
jobs:
build:
name: stagex build+push
# We use a special group that is configured to use github largest runner instance
# This is charged by the minute, so if you want to reduce cost change back to `runs-on: ubuntu-latest`
runs-on:
group: ubuntu-runners
strategy:
matrix:
include:
- target: qos_client
- target: qos_host
- target: qos_enclave
permissions:
id-token: write
contents: read
packages: write
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Docker
uses: ./.github/actions/docker-setup
- name: Run `make ${{ matrix.target }}`
shell: 'script -q -e -c "bash {0}"'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
make -j$(nproc) out/${{ matrix.target }}/index.json
- name: upload to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
env -C out/${{ matrix.target }} tar -cf - . | docker load
for tag in ${tags}; do
docker tag "qos-local/${{ matrix.target }}:latest" "ghcr.io/tkhq/${{ matrix.target }}:${tag}"
done
docker image push --all-tags ghcr.io/tkhq/${{ matrix.target }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::799078726966:role/github-mono
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::799078726966:role/github-qos
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Upload to ECR
shell: 'script -q -e -c "bash {0}"'
run: |
echo "${{ steps.login-ecr.outputs.docker_password_799078726966_dkr_ecr_us_east_1_amazonaws_com }}" | \
docker login \
${{ steps.login-ecr.outputs.registry }} \
-u "${{ steps.login-ecr.outputs.docker_username_799078726966_dkr_ecr_us_east_1_amazonaws_com }}" \
--password-stdin
export BASE_IMAGE_NAME="${{ steps.login-ecr.outputs.registry }}/tkhq/${{ matrix.target }}"
export IMAGE_NAME="${BASE_IMAGE_NAME}:sha-${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
export DIGEST_FILE=/tmp/image-digest-${{ matrix.target }}.sha256
cat out/${{ matrix.target }}/index.json | jq -r .manifests[].digest > "${DIGEST_FILE}"
docker tag "qos-local/${{ matrix.target }}:latest" "$IMAGE_NAME"
for tag in ${tags}; do
docker tag "$IMAGE_NAME" "$BASE_IMAGE_NAME:${tag}"
done
docker image push --all-tags "$BASE_IMAGE_NAME"
echo "Uploaded image $IMAGE_NAME (SHA-256 digest: $(cat $DIGEST_FILE))"