Skip to content

Commit

Permalink
ci: 🚀 automated deploy to production server
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Oct 3, 2023
1 parent 66f0db2 commit d5def9f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 23 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ process.removeAllListeners('warning');
process.on('SIGTERM', () => process.exit());
process.on('SIGINT', () => process.exit());

const { BASE_HREF = '' } = process.env

import {
readFile, writeFile, readdir,
cp, rm,
Expand Down Expand Up @@ -37,7 +39,7 @@ const fixOrCopy = async (
html: [
[
'<base href="/src/" />',
'<base href="/wallet-ui/" />'
`<base href="/${BASE_HREF}" />`
],
[
'../node_modules/',
Expand Down Expand Up @@ -99,7 +101,7 @@ try {
html: [
[
'<base href="/src/" />',
'<base href="/wallet-ui/" />'
`<base href="/${BASE_HREF}" />`
],
[
'../node_modules/',
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master","feat/*"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
check-latest: true
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm run deploy
env:
BASE_HREF: 'wallet-ui/'
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
43 changes: 22 additions & 21 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
name: Deploy static site

on:
# Runs on pushes targeting the default branch
push:
branches: ["master","feat/*"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
group: "static"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: wallet
url: ${{ vars.WEBSITE }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
Expand All @@ -43,8 +30,22 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- shell: bash
env:
SSH_CONFIG: ${{ secrets.SSH_CONFIG }}
SSH_IDENTITY: ${{ secrets.SSH_IDENTITY }}
SSH_IDENTITY_FILE: ${{ secrets.SSH_IDENTITY_FILE }}
run: |
touch ~/.ssh/config
echo $SSH_CONFIG >> ~/.ssh/config
echo $SSH_IDENTITY >> $SSH_IDENTITY_FILE
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOSTNAME }} >> ~/.ssh/known_hosts
- name: Deploy with rsync
env:
GHREF: ${{ GITHUB_REF_NAME }}
RMFEAT: "feat/"
run: |
BRANCH=${GHREF//$RMFEAT/}
rsync -avhPz ./dist/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOSTNAME }}:~/branches/${BRANCH}

0 comments on commit d5def9f

Please sign in to comment.