Skip to content

blogpost + image for #jetzt2 rückblick #39

blogpost + image for #jetzt2 rückblick

blogpost + image for #jetzt2 rückblick #39

Workflow file for this run

---
name: Build website
on:
push: {branches: [ main ]}
workflow_dispatch:
pull_request:
jobs:
determine_urls:
runs-on: ubuntu-latest
outputs:
siteurl: ${{ steps.get_siteurl.outputs.base_url }}
steps:
- name: Obtain pull-request number from event
id: get_siteurl
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
echo "base_url=/_pr-${pull_number}" >> $GITHUB_OUTPUT
else
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
branch_name=${GITHUB_REF/refs\/heads/}
echo "base_url=/${branch_name/\//_}" >> $GITHUB_OUTPUT
else
echo "base_url=" >> $GITHUB_OUTPUT
fi
fi
build:
runs-on: ubuntu-latest
needs: [ determine_urls ]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3'
cache: 'pip'
cache-dependency-path: requirements.txt
- run: pip install -r requirements.txt
- name: make publish
env:
SITEURL: ${{ needs.determine_urls.outputs.siteurl }}
run: make publish PELICANOPTS="-e SITEURL='\"$SITEURL\"'"
- uses: actions/upload-artifact@v2
with:
name: website_pelican-build
path: ./public
deploy_production:
runs-on: ubuntu-latest
needs: [ build ]
if: github.ref == 'refs/heads/main'
environment:
name: production
url: https://chaos.jetzt
steps:
- uses: actions/download-artifact@v2
with:
name: website_pelican-build
- name: deploy
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: .
remote_host: chaos.jetzt
remote_user: web-deploy
remote_key: ${{ secrets.DEPLOY_KEY }}
deploy_dev:
runs-on: ubuntu-latest
needs: [ build, determine_urls ]
if: github.ref != 'refs/heads/main'
environment:
name: development
url: https://dev.chaos.jetzt${{ needs.determine_urls.outputs.siteurl }}
steps:
- uses: actions/download-artifact@v2
with:
name: website_pelican-build
- name: deploy
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: ${{ needs.determine_urls.outputs.siteurl }}
remote_host: dev.chaos.jetzt
remote_user: web-deploy
remote_key: ${{ secrets.DEPLOY_KEY }}