CI/CD Workflow #118
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
name: CI/CD Workflow | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
schedule: | |
- cron: '30 4 * * *' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '10' | |
- name: Install SSH Client and Hugo | |
run: | | |
sudo apt update | |
sudo apt install openssh-client -y | |
wget https://github.com/gohugoio/hugo/releases/download/v0.58.3/hugo_0.58.3_Linux-64bit.tar.gz | |
tar -zxvf hugo_0.58.3_Linux-64bit.tar.gz | |
sudo mv hugo /usr/local/bin/ | |
- name: Set up SSH agent | |
run: | | |
eval $(ssh-agent -s) | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
echo -e "${{ secrets.SSH_PRIVATE_KEY }}" >> ~/.ssh/id_rsa | |
chmod 400 ~/.ssh/id_rsa | |
- name: Node and Hugo versions | |
run: | | |
node --version | |
hugo version | |
- name: Execute Variables and Build | |
env: | |
API_URL: ${{ vars.API_URL }} | |
AUTH_TOKEN: ${{ vars.AUTH_TOKEN }} | |
BASE_URL: ${{ vars.BASE_URL }} | |
CLEAN_URL_FIELD: ${{ vars.CLEAN_URL_FIELD }} | |
EVENTS_PROJECT_ID: ${{ vars.EVENTS_PROJECT_ID }} | |
EVENT_CANCELLED_FIELD: ${{ vars.EVENT_CANCELLED_FIELD }} | |
HUGO_VERSION: ${{ vars.HUGO_VERSION }} | |
LOCATION_FIELD: ${{ vars.LOCATION_FIELD }} | |
NEWS_PROJECT_ID: ${{ vars.NEWS_PROJECT_ID }} | |
PRESS_PROJECT_ID: ${{ vars.PRESS_PROJECT_ID }} | |
run: | | |
npm install | |
node create_md_files/createMdFile.js && hugo | |
- name: Archive build artifacts | |
run: | | |
tar -czvf www.unblock.health_dist.tar.gz public | |
- name: Copy build artifacts to the production server | |
run: | | |
scp -P22 -o StrictHostKeyChecking=no www.unblock.health_dist.tar.gz "${{ secrets.PRODUCTION_USER }}@${{ secrets.PRODUCTION_SERVER_IP }}:" | |
ssh -p22 -o StrictHostKeyChecking=no -t ${{ secrets.PRODUCTION_USER }}@${{ secrets.PRODUCTION_SERVER_IP }} "bash -i update-unblock-health-com.sh" |