Repository navigation
107 lines (96 loc) · 3.63 KB
/
Copy pathpush-sandbox-image.yml
File metadata and controls
107 lines (96 loc) · 3.63 KB
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
102
103
104
105
106
107
name: Push sandbox image
# main / dispatch: push trueforge-sandbox:<sha>, then open a PR that updates sandboxImage.json.
on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'packages/trueforge-core/scripts/sandbox/**'
concurrency:
group: push-sandbox-image
cancel-in-progress: false
permissions:
contents: read
jobs:
build:
name: Build and push sandbox image
uses: truefoundry/github-workflows-public/.github/workflows/build.yml@main
permissions:
id-token: write
contents: read
packages: write
with:
artifactory_oidc_provider_name: github-jfrog-trueforge
artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }}
artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }}
image_artifact_name: trueforge-sandbox
image_tag: ${{ github.sha }}
image_context: packages/trueforge-core/scripts/sandbox
dockerfile_path: packages/trueforge-core/scripts/sandbox/sandbox.Dockerfile
# Dockerfile downloads linux-amd64 helm/nats binaries only.
platforms: linux/amd64
enable_jfrog: true
enable_public_ecr: false
print-uri:
name: Print pushed image URI
needs: [build]
runs-on: ubuntu-latest
steps:
- env:
IMAGE_URI: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }}/trueforge-sandbox:${{ github.sha }}
run: |
echo "Pushed image URI: $IMAGE_URI"
echo "\`$IMAGE_URI\`" >> "$GITHUB_STEP_SUMMARY"
pin:
name: Open SANDBOX_IMAGE_URI pin PR
if: github.ref == 'refs/heads/main'
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_ID }}
private-key: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_PRIVATE_KEY }}
- uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
- id: image
env:
REPO: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }}
SHA: ${{ github.sha }}
run: echo "uri=${REPO}/trueforge-sandbox:${SHA}" >> "$GITHUB_OUTPUT"
- name: Write sandboxImage.json
id: pin-uri
env:
IMAGE_URI: ${{ steps.image.outputs.uri }}
run: |
set -euo pipefail
path=packages/trueforge-core/src/core/sandbox/sandboxImage.json
jq -n --arg uri "$IMAGE_URI" '{uri: $uri}' >"$path"
if git diff --quiet -- "$path"; then
echo "changed=false" >>"$GITHUB_OUTPUT"
else
echo "changed=true" >>"$GITHUB_OUTPUT"
fi
- if: steps.pin-uri.outputs.changed == 'true'
run: bash scripts/changeset-sandbox-image.sh
- uses: peter-evans/create-pull-request@v8
with:
# GitHub will not start new workflow runs from GITHUB_TOKEN (anti-recursion).
# ci.yml would never run (or sit approval-required); required checks stay
# pending and this pin PR cannot merge. An App token is treated as a user.
token: ${{ steps.app-token.outputs.token }}
branch: release-sandbox-image
base: main
commit-message: 'chore: update sandbox image ${{ github.sha }}'
title: 'chore: update sandbox image ${{ github.sha }}'
body: |
Pushed `${{ steps.image.outputs.uri }}`. Merge so `release.yml` can publish the pin.
Existing tenants stay on `build_metadata`.
add-paths: |
packages/trueforge-core/src/core/sandbox/sandboxImage.json
.changeset