-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (78 loc) · 3.65 KB
/
blank.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
name: GitHub Pages
env:
branch_name: gh-pages
folder_name: .gh-pages
commit_message: Deploy
readme_message: "This branch was automatically generated by Github Actions."
on:
push:
branches: [master, main]
jobs:
Deploy: # Will copy `dist/*` files to `gh-pages` branch for deploying on GHP
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: "16"
- uses: actions/checkout@v2
- name: Info
run: node -v && pwd && ls -la
- name: Create Git user
run: git config --global user.email "${{github.actor}}@users.noreply.github.com" && git config --global user.name "${{github.actor}}"
- name: Github NPM log in
run: echo "//npm.pkg.github.com/:_authToken=${{secrets.GITHUB_TOKEN}}" > ~/.npmrc
- name: Init && Build
run: npm ci && npm run build
- name: Init Git
run: mkdir $folder_name && cd $folder_name &&
echo "----------------";
echo "--- Init Git ---";
echo "----------------";
git init && git remote add origin https://github.com/${{github.repository}}.git &&
if [[ $(git ls-remote origin $branch_name | wc -w) -ne 0 ]]; then
echo "----------------";
echo "--- Git pull ---";
echo "----------------";
git pull origin $branch_name;
if [[ $(ls | wc -w) -ne 0 ]]; then
echo "-----------------------------";
echo "--- Remove files from Git ---";
echo "-----------------------------";
git rm -r --cached *;
echo "------------------------------------";
echo "--- Remove files from the folder ---";
echo "------------------------------------";
rm -r $(ls);
fi;
fi;
echo "--- Git status ---";
echo "------------------";
git status;
- name: Move static and generated files && and check files
run: cp -r ./dist/* ./$folder_name/ &&
cd $folder_name && pwd && ls -l &&
echo "-------------------------";
echo "--- Files were copied ---";
echo "-------------------------";
- name: Add README.MD
run: cd $folder_name && echo $readme_message > README.MD
- name: Git push
run: cd $folder_name &&
git add . &&
if [[ $(git status) == *"nothing to commit, working tree clean"* ]]; then
echo "----------------------------------------------------";
echo "--- No changes. Skip deployment for this commit. ---";
echo "----------------------------------------------------";
elif [[ $(cd .. && git pull) != "Already up to date." ]]; then
echo "-----------------------------------------------------------------";
echo "--- There is a newer commit. Skip deployment for this commit. ---";
echo "-----------------------------------------------------------------";
else
echo "-------------------";
echo "--- Push commit ---";
echo "-------------------";
git commit -m "$commit_message" && git push "https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git" master:$branch_name;
echo "-------------------";
echo "--- Pushed ---";
echo "-------------------";
fi;