This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
Merge pull request #91 from nickveenhof/patch-1 #246
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 Pipeline | |
on: | |
push: | |
branches: | |
- "*" | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [19.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
- run: npm ci | |
- run: npm test | |
- run: npm run build | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build | |
path: build | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: build | |
- name: remove old build | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DROPLET_IP_ADDRESS }} | |
username: ${{ secrets.SSHUSERNAME }} | |
password: ${{ secrets.SSHPASSWORD }} | |
script: | | |
echo ${{ secrets.SSHPASSWORD }} | sudo -S rm -rf /var/www/badging.allinopensource.org/* | |
mkdir -p /var/www/badging.allinopensource.org/ | |
- name: deploy new build | |
uses: garygrossgarten/github-action-scp@release | |
with: | |
host: ${{ secrets.DROPLET_IP_ADDRESS }} | |
username: ${{ secrets.SSHUSERNAME }} | |
password: ${{ secrets.SSHPASSWORD }} | |
local: ${{ github.workspace }}/build | |
remote: "/var/www/badging.allinopensource.org/" | |
- name: restart nginx | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DROPLET_IP_ADDRESS }} | |
username: ${{ secrets.SSHUSERNAME }} | |
password: ${{ secrets.SSHPASSWORD }} | |
script: | | |
echo ${{ secrets.SSHPASSWORD }} | sudo -S systemctl restart nginx |