Skip to content

Commit d7a1f67

Browse files
[script bundle] Add action to update script bundle in gh-pages (#1559)
Summary: Adds a manually triggered action to update the script bundle stored in github pages. Type of change: /kind cleanup. Test Plan: Tested on my fork. Saw that it adds the bundle to gh-pages as expected. Also tested that a rerun of the workflow with no changes won't attempt an empty commit. Signed-off-by: James Bartlett <jamesbartlett@pixielabs.ai>
1 parent 68fc3cf commit d7a1f67

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: update-script-bundle
3+
on:
4+
workflow_dispatch:
5+
permissions:
6+
contents: read
7+
jobs:
8+
build-script-bundle:
9+
name: Build Script Bundle
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
13+
with:
14+
fetch-depth: 0
15+
- name: Add pwd to git safe dir
16+
run: git config --global --add safe.directory `pwd`
17+
- name: Install Pixie CLI
18+
# yamllint disable rule:indentation
19+
run: |
20+
jq_script=(
21+
'.[] | '
22+
'select(.name == "cli") | '
23+
'.artifact | '
24+
'map(select(.versionStr | contains("-") | not))[0] | '
25+
'.availableArtifactMirrors[] | '
26+
'select(.artifactType == "AT_LINUX_AMD64") | '
27+
'.urls[0]'
28+
)
29+
download_link=$(curl -fssL "https://artifacts.px.dev/artifacts/manifest.json" | jq "${jq_script[*]}" -r )
30+
curl -fssL "${download_link}" -o px
31+
chmod +x px
32+
# yamllint enable rule:indentation
33+
- name: Build bundle
34+
shell: bash
35+
run: |
36+
export PATH="$PATH:$(pwd)"
37+
cd src/pxl_scripts
38+
make bundle-oss.json
39+
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
40+
with:
41+
name: bundle
42+
path: src/pxl_scripts/bundle-oss.json
43+
update-gh-pages-bundle:
44+
name: Update bundle in gh-pages
45+
runs-on: ubuntu-latest
46+
needs: build-script-bundle
47+
concurrency: gh-pages
48+
permissions:
49+
contents: write
50+
steps:
51+
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
52+
with:
53+
fetch-depth: 0
54+
ref: gh-pages
55+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
56+
- name: Import GPG key
57+
env:
58+
BUILDBOT_GPG_KEY_B64: ${{ secrets.BUILDBOT_GPG_KEY_B64 }}
59+
run: |
60+
echo "${BUILDBOT_GPG_KEY_B64}" | base64 --decode | gpg --no-tty --batch --import
61+
- name: Setup git
62+
shell: bash
63+
env:
64+
BUILDBOT_GPG_KEY_ID: ${{ secrets.BUILDBOT_GPG_KEY_ID }}
65+
run: |
66+
git config --global user.name 'pixie-io-buildbot'
67+
git config --global user.email 'build@pixielabs.ai'
68+
git config --global user.signingkey "${BUILDBOT_GPG_KEY_ID}"
69+
git config --global commit.gpgsign true
70+
- name: Push to gh-pages
71+
shell: bash
72+
env:
73+
GH_TOKEN: ${{ secrets.BUILDBOT_GH_API_TOKEN }}
74+
GIT_SSH_COMMAND: "ssh -i /tmp/ssh.key"
75+
# yamllint disable rule:indentation
76+
run: |
77+
mkdir -p pxl_scripts
78+
cp bundle/bundle-oss.json pxl_scripts/bundle.json
79+
80+
git add pxl_scripts/bundle.json
81+
if [[ $(git status --porcelain=v1 --untracked-files=no | wc -l) -eq 0 ]]; then
82+
echo "No updates to script bundle, exiting."
83+
exit 0
84+
fi
85+
git commit -s -m "Update PxL script bundle"
86+
git push origin "gh-pages"
87+
# yamllint enable rule:indentation

0 commit comments

Comments
 (0)