Skip to content

Commit

Permalink
chore: setup Github Workflows with surge.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Apr 11, 2023
1 parent 1fd57c3 commit b60923d
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build & Deploy dev

on:
push:
branches:
- dev

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
DEPLOY_TO_DOMAIN: https://dev.adamant.im

jobs:
setup-build-publish-deploy:
name: Build and Deploy dev branch
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3

- name: Setup Node version 🍀
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies ⚙️
run: npm ci

- name: Build PWA 🛠️
run: npm run build

- name: Archive artifacts 📁
uses: actions/upload-artifact@v3
with:
path: dist

- name: Deploy to surge 🚀
run: |
npm install --global surge
surge ./dist $DEPLOY_TO_DOMAIN --token $SURGE_TOKEN
40 changes: 40 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build & Deploy master

on:
push:
branches:
- master

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
DEPLOY_TO_DOMAIN: https://msg2.adamant.im

jobs:
setup-build-publish-deploy:
name: Build and Deploy master branch
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3

- name: Setup Node version 🍀
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies ⚙️
run: npm ci

- name: Build PWA 🛠️
run: npm run build

- name: Archive artifacts 📁
uses: actions/upload-artifact@v3
with:
path: dist

- name: Deploy to surge 🚀
run: |
npm install --global surge
surge ./dist $DEPLOY_TO_DOMAIN --token $SURGE_TOKEN
30 changes: 30 additions & 0 deletions .github/workflows/preview-teardown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Preview Teardown Workflow

on:
pull_request:
types:
- closed

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
PREVIEW_DOMAIN: https://msg-adamant-pr-${{ github.event.number }}.surge.sh

jobs:
tear-down-preview-domain:
name: Tear down preview domain job
runs-on: ubuntu-latest
environment: testing
permissions:
pull-requests: write
steps:
- name: Tear down ${{ env.PREVIEW_DOMAIN }} preview domain 🥲
run: |
npm install --global surge
surge teardown ${{ env.PREVIEW_DOMAIN }} --token ${{ secrets.SURGE_TOKEN }}
- name: Comment PR 💬
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Successfully tore down ${{ env.PREVIEW_DOMAIN }} 🥲
comment_tag: teardown-message
52 changes: 52 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Preview Workflow

on:
pull_request:
type:
- opened
- synchronize
- reopened
- closed

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
PREVIEW_DOMAIN: https://msg-adamant-pr-${{ github.event.number }}.surge.sh

jobs:
build-and-deploy-to-surge:
name: Build and Deploy to surge
runs-on: ubuntu-latest
environment: testing
permissions:
pull-requests: write
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3

- name: Setup Node version 🍀
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies ⚙️
run: npm ci

- name: Build PWA 🛠️
run: npm run build

- name: Archive artifacts 📁
uses: actions/upload-artifact@v3
with:
path: dist

- name: Deploy to surge 🚀
run: |
npm install --global surge
surge ./dist ${{ env.PREVIEW_DOMAIN }} --token ${{ secrets.SURGE_TOKEN }}
- name: Comment PR 💬
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Deployed to ${{ env.PREVIEW_DOMAIN }} 🚀
comment_tag: deploy-message

0 comments on commit b60923d

Please sign in to comment.