-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Shaikh-Ubaid/ci_deploy
CI: Add CI for auto deploying site
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- name: Checkout Master | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- name: Install Dependencies | ||
shell: bash -l {0} | ||
run: npm i | ||
|
||
- name: Build Site | ||
shell: bash -l {0} | ||
run: | | ||
npm run build | ||
npm run export | ||
- name: Misc Steps | ||
shell: bash -l {0} | ||
run: | | ||
mv out deploy | ||
touch deploy/.nojekyll | ||
echo "dev.lfortran.org" > deploy/CNAME | ||
- name: SSH Setup | ||
shell: bash -l {0} | ||
run: | | ||
mkdir ~/.ssh | ||
chmod 700 ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
eval "$(ssh-agent -s)" | ||
if [[ "${GIT_DEPLOY_PRIVATE_SSH_KEY}" == "" ]]; then | ||
echo "Note: GIT_DEPLOY_PRIVATE_SSH_KEY is empty, skipping..." | ||
exit 0 | ||
fi | ||
ssh-add <(echo "$GIT_DEPLOY_PRIVATE_SSH_KEY" | base64 -d) | ||
env: | ||
GIT_DEPLOY_PRIVATE_SSH_KEY: ${{ secrets.GIT_DEPLOY_PRIVATE_SSH_KEY }} | ||
|
||
- name: GIT Setup Config | ||
shell: bash -l {0} | ||
run: | | ||
git config user.email "noreply@deploy" | ||
git config user.name "Deploy" | ||
- name: GIT Checkout gh-pages and Add Deploy files | ||
shell: bash -l {0} | ||
run: | | ||
cp deploy/ ../deploy -r | ||
git reset --hard | ||
git fetch origin | ||
git checkout gh-pages | ||
rm -rf * | ||
mv ../deploy/* . | ||
- name: GIT Add and Commit | ||
shell: bash -l {0} | ||
run: | | ||
git add . | ||
COMMIT_MESSAGE="Deploying on $(date "+%Y-%m-%d %H:%M:%S")" | ||
git commit -m "${COMMIT_MESSAGE}" | ||
- name: GIT Deploy | ||
run: git push origin gh-pages |