Skip to content

Commit 31ad08e

Browse files
authored
Add workflow to deploy build from source
1 parent fd6ea98 commit 31ad08e

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy Build from Source
2+
3+
on:
4+
repository_dispatch:
5+
types: [deploy-build]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout beta repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: main
18+
19+
- name: Download and extract build
20+
run: |
21+
SOURCE_REPO="${{ github.event.client_payload.source_repo }}"
22+
RELEASE_TAG="${{ github.event.client_payload.release_tag }}"
23+
ASSET_NAME="${{ github.event.client_payload.asset_name }}"
24+
ASSET_URL="https://github.com/${SOURCE_REPO}/releases/download/${RELEASE_TAG}/${ASSET_NAME}"
25+
curl -L -o build.zip "${ASSET_URL}"
26+
unzip build.zip -d temp-build
27+
28+
- name: Clear and copy to subfolder
29+
run: |
30+
SUBFOLDER="${{ github.event.client_payload.subfolder }}"
31+
rm -rf "${SUBFOLDER}"/*
32+
mkdir -p "${SUBFOLDER}"
33+
mv temp-build/* "${SUBFOLDER}/"
34+
35+
- name: Commit and push
36+
run: |
37+
SUBFOLDER="${{ github.event.client_payload.subfolder }}"
38+
SOURCE_REPO="${{ github.event.client_payload.source_repo }}"
39+
RELEASE_TAG="${{ github.event.client_payload.release_tag }}"
40+
git config --global user.name 'github-actions[bot]'
41+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
42+
git add "${SUBFOLDER}"
43+
if git diff --staged --quiet; then
44+
echo "No changes to commit"
45+
else
46+
git commit -m "Deploy ${SOURCE_REPO} build to ${SUBFOLDER} from release ${RELEASE_TAG}"
47+
git push origin main
48+
fi

0 commit comments

Comments
 (0)