Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new build script #52

Merged
merged 8 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 209 additions & 0 deletions .github/workflows-old/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# This workflow will do a clean install of node dependencies, 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: Website Builder

on:
push:
branches: [ main ]
pull_request:
branches: [ main, PR-Add-Events-Section ]

jobs:
install: # Install deps
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# CACHE!
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
name: actions/cache@v2 - yarn cache
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile # Install deps -no cache so just install fresh
if: steps.yarn-cache.outputs.cache-hit != 'true'
working-directory: ./frontend
- name: Install project dependencies from cache
run: yarn --prefer-offline --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit == 'true'
working-directory: ./frontend
# Upload node_modules to download for other steps
- uses: actions/cache@v2
name: actions/cache@v2 - upload node_modules for other jobs
id: module-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ./frontend/node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.sha }}-

lint: # Lint!
runs-on: ubuntu-latest
needs: [install]

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# Get CACHE!
- uses: actions/cache@v2
name: actions/cache@v2 - download node_modules
id: moduleCache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ./frontend/node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.sha }}-

# Restore yarn cache if above fails
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# if: steps.moduleCache.outputs.cache-hit != 'true'
# run: echo "::set-output name=dir::$(yarn cache dir)"

# - uses: actions/cache@v2
# name: actions/cache@v2 - download yarn cache
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# if: steps.moduleCache.outputs.cache-hit != 'true'
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# # Install from cache if node.js not found
# - run: yarn install --frozen-lockfile # Install deps - no cache so just install fresh
# if: steps.moduleCache.outputs.cache-hit != 'true' && steps.yarn-cache.outputs.cache-hit != 'true'
# working-directory: ./frontend
# - name: Install project dependencies from cache
# run: yarn --prefer-offline --frozen-lockfile
# if: steps.moduleCache.outputs.cache-hit != 'true' && steps.yarn-cache.outputs.cache-hit == 'true'
# working-directory: ./frontend


# Lint
- name: Lint using ESLint
run: yarn run lint
working-directory: ./frontend

build-deploy: # Now build & deploy the repo

runs-on: ubuntu-latest
needs: [install]

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Get cache
# CACHE!
- uses: actions/cache@v2
name: actions/cache@v2 - download node_modules
id: moduleCache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ./frontend/node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.sha }}-

# Restore from yarn
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"
# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# - run: yarn install --frozen-lockfile # Install deps -no cache so just install fresh
# if: steps.yarn-cache.outputs.cache-hit != 'true'
# working-directory: ./frontend
# - name: Install project dependencies from cache
# run: yarn --prefer-offline --frozen-lockfile
# if: steps.yarn-cache.outputs.cache-hit == 'true'
# working-directory: ./frontend

# Prepare dest
- name: Prepare repo/ as a git repo
run: |
mkdir repo
cd repo
echo Cloning repo...
git clone https://github.com/$GITHUB_REPOSITORY --branch gh-pages ./
echo Deleteing dirs...
find . ! -wholename './.git/*' ! -wholename './.git' ! -wholename '.' -type d -exec rm -rfv {} +
echo Deleteing files...
find . ! -wholename './.git/*' -type f -exec echo {} +
echo Staging...
git add .

# BUILD
- run: yarn run build
env:
CI: "false"
working-directory: ./frontend

# DEPLOY
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
# Artifact name
name: Website Build
# A file, directory or wildcard pattern that describes what to upload
path: frontend/build/
- name: Copy build files
run: cp -va ./build/. ../repo/
working-directory: ./frontend
- name: Commit changes
if: ${{ contains(github.ref, 'main') }} # Only run if this repo is main and the development branch
run: |
cd repo
echo Setting git settings
git config user.email "kishansambhi@hotmail.co.uk"
git config user.name "Kishan Build Agent"
git add .
git commit -m "Build push for commit $GITHUB_SHA run ID $GITHUB_RUN_ID"
continue-on-error: true # Errors if no code changes applied, hence why skipped
- name: GitHub Push
uses: ad-m/github-push-action@v0.5.0
if: ${{ contains(github.ref, 'main') && success() }} # Only run if this repo is main and the development branch
with:
# Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})
# repository: # optional, default is
# Destination branch to push changes
branch: gh-pages
# Determines if force push is used
force: true
# Directory to change to before pushing.
directory: repo
Loading