-
Notifications
You must be signed in to change notification settings - Fork 19
120 lines (107 loc) · 4 KB
/
Copy pathpush-js-runtime.yml
File metadata and controls
120 lines (107 loc) · 4 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
108
109
110
111
112
113
114
115
116
117
118
119
120
name: push-js-runtime
permissions:
contents: write
on:
workflow_dispatch:
inputs:
runtime_type:
description: "Which JS runtime to push"
required: true
type: choice
options:
- activity-js-runtime
- workflow-js-runtime
- webhook-js-runtime
tag:
description: "The tag to be used when pushing the runtime to Docker Hub."
required: true
type: string
ref:
description: "The ref (branch or SHA) to process"
required: false
type: string
push_to_main:
description: "Push directly to main instead of creating a PR"
required: false
type: boolean
default: false
defaults:
run:
shell: bash -xe {0}
jobs:
push-js-runtime:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.inputs.ref }}
persist-credentials: false
- uses: nixbuild/nix-quick-install-action@v35
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_conf: |
extra-substituters = https://obeli-sk.cachix.org
extra-trusted-public-keys = obeli-sk.cachix.org-1:31iM9GWSEhAXvvuTWQ7CvAcwvgRzsuJ9yJghywSd3Jw=
- name: Populate the nix store
run: nix develop --command echo
- name: Add latest obelisk to PATH
run: |
./scripts/get-latest-obelisk-bin-dir.sh >> "$GITHUB_PATH"
- name: Log in to Docker Hub
run: |
echo "$DOCKER_HUB_TOKEN" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Push JS runtime
run: |
SCRIPT="./scripts/push-${RUNTIME_TYPE}.sh"
nix develop --command "$SCRIPT" "$TAG"
env:
RUNTIME_TYPE: ${{ github.event.inputs.runtime_type }}
TAG: ${{ github.event.inputs.tag }}
- name: Configure git before push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://${{ secrets.GH_TOKEN_PR_RW }}@github.com/${{ github.repository }}.git"
- name: Generate Unique Branch Name
id: branch-name
run: echo "branch_name=bump-${RUNTIME_TYPE}-$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT"
env:
RUNTIME_TYPE: ${{ github.event.inputs.runtime_type }}
- name: Push directly to main
if: ${{ github.event.inputs.push_to_main == 'true' }}
run: |
git add .
git commit -m "chore: Bump ${RUNTIME_TYPE} runtime to ${TAG}"
git push origin main
env:
RUNTIME_TYPE: ${{ github.event.inputs.runtime_type }}
TAG: ${{ github.event.inputs.tag }}
- name: Create a PR
if: ${{ github.event.inputs.push_to_main != 'true' }}
run: |
git checkout -b "${{ steps.branch-name.outputs.branch_name }}"
git add .
git commit -m "chore: Bump ${RUNTIME_TYPE} runtime to ${TAG}"
git push origin "${{ steps.branch-name.outputs.branch_name }}"
OWNER="${GITHUB_REPOSITORY%%/*}"
REPO="${GITHUB_REPOSITORY##*/}"
cat > payload.json <<EOF
{
"title": "chore: Bump ${RUNTIME_TYPE} runtime to ${TAG}",
"head": "${{ steps.branch-name.outputs.branch_name }}",
"base": "main",
"body": ""
}
EOF
curl -v --fail -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/$OWNER/$REPO/pulls" \
--data "@payload.json"
env:
RUNTIME_TYPE: ${{ github.event.inputs.runtime_type }}
TAG: ${{ github.event.inputs.tag }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR_RW }}