New deployment workflow #15
1 changed files with 62 additions and 0 deletions
62
.forgejo/workflows/deploy.yaml
Normal file
62
.forgejo/workflows/deploy.yaml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
name: deploy blog
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- staging
|
||||
- production
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: apk --no-cache add hugo python3 py3-pip git
|
||||
|
||||
- name: Check install
|
||||
run: |
|
||||
cat /etc/os-release
|
||||
git version
|
||||
hugo version
|
||||
python --version
|
||||
|
||||
- name: Checkout repo
|
||||
run: |
|
||||
git clone -b ${{ forgejo.ref_name }} https://git.berlin.ccc.de/cccb-website-team/www.git .
|
||||
git status
|
||||
|
||||
- name: Install Python depenndencies
|
||||
run: python -m pip install -r requirements.txt --break-system-packages
|
||||
|
||||
- name: Render site
|
||||
run: ./build.sh
|
||||
|
||||
- name: Setup SSH key
|
||||
if: forgejo.ref_name == 'staging'
|
||||
run: |
|
||||
mkdir -p .ssh
|
||||
echo ${{ secrets.SSH_PRIVATE_KEY_STAGING }} > .ssh/id_ed25519
|
||||
chmod 600 .ssh/id_ed25519
|
||||
ssh-keygen -f .ssh/id_ed25519 -y > .ssh/id_ed25519.pub
|
||||
cat .ssh/id_ed25519.pub
|
||||
|
||||
- name: Setup SSH key
|
||||
if: forgejo.ref_name == 'production'
|
||||
run: |
|
||||
mkdir -p .ssh
|
||||
echo ${{ secrets.SSH_PRIVATE_KEY_PRODUCTION }} > .ssh/id_ed25519
|
||||
chmod 600 .ssh/id_ed25519
|
||||
ssh-keygen -f .ssh/id_ed25519 -y > .ssh/id_ed25519.pub
|
||||
cat .ssh/id_ed25519.pub
|
||||
|
||||
- name: Sync rendered site to staging
|
||||
if: forgejo.ref_name == 'staging'
|
||||
run: rsync -var -e 'ssh -i .ssh/id_ed25519' ./public/ deploy@www.berlin.ccc.de:srv/http/www-staging/
|
||||
continue-on-error: true
|
||||
- name: Sync rendered site to production
|
||||
if: forgejo.ref_name == 'production'
|
||||
run: rsync -var -e 'ssh -i .ssh/id_ed25519' ./public/ deploy@www.berlin.ccc.de:srv/http/www/
|
||||
continue-on-error: true
|
||||
|
||||
- name: Cleanup
|
||||
run: rm -rf .ssh
|
||||
Loading…
Add table
Add a link
Reference in a new issue