-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (76 loc) · 2.54 KB
/
deploy-pr.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
name: Build and Deploy Development Branch
on:
pull_request:
branches: [ staging ]
types: [ opened, synchronize, closed ]
paths-ignore:
- 'ios/**'
- 'android/**'
- '.vscode/**'
- '.github/**'
- '**.md'
env:
PR_REPO_NAME: acchymns-pr-${{ github.event.pull_request.node_id }}
jobs:
create-repo:
if: ${{ github.event.action == 'opened' && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Create new repository for temporary deployment
uses: octobay/create-repository-action@v1
with:
name: ${{ env.PR_REPO_NAME }}
org: ACC-Hymns
private-repo: false
access-token: ${{ secrets.DEPLOYMENT_PAT }}
initialize-repo: true
delete-repo:
if: ${{ github.event.action == 'closed' && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Delete repository for temporary deployment
uses: octobay/delete-repository-action@v1
with:
name: ACC-Hymns/${{ env.PR_REPO_NAME }}
access-token: ${{ secrets.DEPLOYMENT_PAT }}
build-and-deploy:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token
- name: Set GitHub Actions as Commit Author
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Checkout Repo
uses: actions/checkout@v4
with:
path: 'build'
- name: Build
run: |
cd build
export VITE_BASE_URL="/${{ env.PR_REPO_NAME }}/"
export VITE_GIT_BRANCH="$GITHUB_HEAD_REF"
npm i
npm run deploy-check
npm run build
npx cap copy web
cd ..
- name: Checkout Dev Target
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/checkout@v4
with:
repository: ACC-Hymns/${{ env.PR_REPO_NAME }}
path: 'deploy'
token: ${{ secrets.DEPLOYMENT_PAT }}
- name: Push files to target
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cd deploy
git checkout -B gh-pages
cp -r ../build/dist/* .
cp index.html 404.html # This is to avoid 404 errors on reload (Ugly fix but okay I guess)
touch .nojekyll
git add .
git commit -m $GITHUB_SHA
git push --force -u origin gh-pages