Skip to content

Commit

Permalink
Replace CD workflow with staging and production deployments
Browse files Browse the repository at this point in the history
This will continiously deploy the main branch to staging as before.
Rather than merging to production , production deployments will now be
performed on release.
  • Loading branch information
cmil committed Sep 20, 2024
1 parent 4e2b934 commit b5bd682
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 40 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/cd.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "20.x"
- name: Restore node_modules
uses: actions/cache@v3
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy to production

on:
workflow_dispatch:
release:
types: [published]

jobs:
production:
uses: dracor-org/einakter/.github/workflows/deployment.yml@main
with:
host: dracor.org
deploy-path: /var/www/einakter
secrets:
deploy-key: ${{ secrets.DRACOR_ORG_DEPLOY_KEY }}
deploy-user: ${{ secrets.DRACOR_ORG_DEPLOY_USER }}
15 changes: 15 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Deploy to staging

on:
push:
branches: [main]

jobs:
staging:
uses: dracor-org/einakter/.github/workflows/deployment.yml@main
with:
host: staging.dracor.org
deploy-path: /var/www/einakter
secrets:
deploy-key: ${{ secrets.DRACOR_ORG_DEPLOY_KEY }}
deploy-user: ${{ secrets.DRACOR_ORG_DEPLOY_USER }}
50 changes: 50 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deployment

on:
workflow_call:
inputs:
host:
required: true
type: string
deploy-path:
required: true
type: string
secrets:
deploy-key:
required: true
deploy-user:
required: true

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-tags: true
fetch-depth: 0
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20.x"
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

- run: yarn install
- run: yarn test --watch=false
- run: yarn build

- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ secrets.deploy-key }}

- name: Deploy to ${{ inputs.host }}
run: |
rsync -rlvz --delete \
--exclude=robots.txt \
--exclude=google*.html \
-e 'ssh -o StrictHostKeyChecking=no' \
build/ \
${{ secrets.deploy-user }}@${{ inputs.host }}:${{ inputs.deploy-path }}/

0 comments on commit b5bd682

Please sign in to comment.