#Jetzt5 Rückblick #92
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 }} | |
upload_dir: ${{ steps.get_siteurl.outputs.branch_dir }} | |
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") | |
pull_dir="/_pr-${pull_number}" | |
echo "base_url=https://dev.chaos.jetzt${pull_dir}" >> $GITHUB_OUTPUT | |
echo "branch_dir=${pull_dir}" >> $GITHUB_OUTPUT | |
else | |
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then | |
branch_name=${GITHUB_REF/refs\/heads/} | |
branch_dir="/${branch_name/\//_}" | |
echo "branch_dir=${branch_dir}" >> $GITHUB_OUTPUT | |
echo "base_url=https://dev.chaos.jetzt/${branch_dir}" >> $GITHUB_OUTPUT | |
else | |
echo "base_url=https://chaos.jetzt" >> $GITHUB_OUTPUT | |
echo "branch_dir=" >> $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: ${{ 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.upload_dir }} | |
remote_host: dev.chaos.jetzt | |
remote_user: web-deploy | |
remote_key: ${{ secrets.DEPLOY_KEY }} |