-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (61 loc) · 2.19 KB
/
deploy.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
name: Webpack-build
on:
push:
branches:
- main
jobs:
Build:
name: Publish Build
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore CI Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-14-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Build Code
run: yarn build
env:
PUBLIC_URL: https://ayayem.github.io/new-world-skill-xp/
- name: Push new code
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo -e "\n# Initialize some useful variables"
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
BRANCH_OR_TAG=`awk -F/ '{print $2}' <<< $GITHUB_REF`
CURRENT_BRANCH=`awk -F/ '{print $NF}' <<< $GITHUB_REF`
if [ "$BRANCH_OR_TAG" == "heads" ]; then
SOURCE_TYPE="branch"
else
SOURCE_TYPE="tag"
fi
echo -e "\n# Checkout the repo in the target branch"
TARGET_BRANCH="build"
git clone $REPO out -b $TARGET_BRANCH
echo -e "\n# Remove any old files in the build folder"
rm -rfv out/build/*
echo -e "\n# Move the generated docs to the newly-checked-out repo, to be committed and pushed"
rsync -vaI README.md out/
rsync -vaI build/ out
echo -e "\n# Removing TSC incremental file"
rm -rfv out/**/*.tsbuildinfo
echo -e "\n# Commit and push"
cd out
git add --all .
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_EMAIL}"
git commit -m "build: tsc build for ${GITHUB_SHA}" || true
git push origin $TARGET_BRANCH
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }}
GITHUB_ACTOR: AyAyEm
GITHUB_EMAIL: ${{ secrets.EMAIL }}