Skip to content

Commit

Permalink
Merge pull request #1 from Shaikh-Ubaid/ci_deploy
Browse files Browse the repository at this point in the history
CI: Add CI for auto deploying site
  • Loading branch information
Shaikh-Ubaid authored Aug 12, 2022
2 parents 7a6840b + c01a2af commit 27a7646
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/deploy.yml
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

0 comments on commit 27a7646

Please sign in to comment.