diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7bf32f2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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