www/.github/workflows/release.yml

127 lines
3.8 KiB
YAML
Raw Normal View History

2023-06-13 12:47:07 +02:00
name: Release website
2023-06-12 19:58:53 +02:00
on:
push:
branches:
- staging
- production
2023-06-14 12:25:13 +02:00
pull_request:
2023-06-12 19:58:53 +02:00
workflow_dispatch:
jobs:
pages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
- name: Build pages
run: hugo $(cat .hugo-params)
- uses: actions/upload-artifact@v3
name: Upload pages
with:
name: pages
path: public
calendar:
needs: [ pages ]
runs-on: ubuntu-latest
steps:
2023-06-13 23:00:49 +02:00
- name: Add de_DE.UTF-8 locale
run: |
2023-06-13 23:03:40 +02:00
sudo apt-get update
sudo apt-get -y install locales
sudo locale-gen de_DE.UTF-8
2023-06-12 19:58:53 +02:00
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
- name: Download pages
uses: actions/download-artifact@v3
with:
name: pages
2023-06-13 23:23:43 +02:00
path: public/
2023-06-12 19:58:53 +02:00
- name: Generate calendars
run: python tools/merge_cals.py
- name: Copy calendar to output dir
run: cp static/all.ics public/all.ics
- name: Update homepage with latest event
2023-06-13 23:00:49 +02:00
run: upcoming="$(python tools/gen_upcoming.py static/all.ics 20 5 | tr '\n' ' ')" && sed -i "s#CALENDAR#$upcoming#g" public/index.html
2023-06-12 19:58:53 +02:00
- uses: actions/upload-artifact@v3
name: Upload pages
with:
name: enhanced_pages
path: public
2023-06-13 23:00:49 +02:00
2023-06-12 19:58:53 +02:00
staging:
needs: [ calendar ]
runs-on: ubuntu-latest
environment: staging
if: github.ref == 'refs/heads/staging' && github.event_name == 'push'
steps:
- name: Download pages
uses: actions/download-artifact@v3
with:
name: enhanced_pages
2023-06-13 23:23:43 +02:00
path: public
2023-06-12 19:58:53 +02:00
- name: Generate timestamp
2023-06-13 23:56:05 +02:00
run: echo "timestamp=$(date -u +'%Y-%m-%dT%H%M%SZ')" >> $GITHUB_ENV
2023-06-13 23:23:43 +02:00
- name: Create Release Archive
uses: thedoctor0/zip-release@0.7.1
with:
type: zip
2023-06-14 11:39:36 +02:00
filename: ../release-staging-${{ env.timestamp }}.zip
2023-06-13 23:23:43 +02:00
directory: public
2023-06-12 19:58:53 +02:00
- name: Create Release
2023-06-13 23:23:43 +02:00
uses: ncipollo/release-action@v1.12.0
2023-06-12 19:58:53 +02:00
with:
2023-06-13 23:23:43 +02:00
tag: staging-${{ env.timestamp }}
name: Website staging version ${{ env.timestamp }}
body: Website staging version ${{ env.timestamp }}
2023-06-14 11:39:36 +02:00
artifacts: release-staging-${{ env.timestamp }}.zip
2023-06-13 23:23:43 +02:00
token: ${{ secrets.GITHUB_TOKEN }}
2023-06-12 19:58:53 +02:00
2023-06-14 12:26:08 +02:00
production:
2023-06-12 19:58:53 +02:00
needs: [ calendar ]
runs-on: ubuntu-latest
environment: production
if: github.ref == 'refs/heads/production' && github.event_name == 'push'
steps:
- name: Download pages
uses: actions/download-artifact@v3
with:
name: enhanced_pages
2023-06-13 23:23:43 +02:00
path: public
2023-06-12 19:58:53 +02:00
- name: Generate timestamp
2023-06-13 23:56:05 +02:00
run: echo "timestamp=$(date -u +'%Y-%m-%dT%H%M%SZ')" >> $GITHUB_ENV
2023-06-13 23:23:43 +02:00
- name: Create Release Archive
uses: thedoctor0/zip-release@0.7.1
with:
type: zip
2023-06-14 11:39:36 +02:00
filename: ../release-production-${{ env.timestamp }}.zip
2023-06-13 23:23:43 +02:00
directory: public
2023-06-12 19:58:53 +02:00
- name: Create Release
2023-06-13 23:23:43 +02:00
uses: ncipollo/release-action@v1.12.0
2023-06-12 19:58:53 +02:00
with:
2023-06-13 23:23:43 +02:00
makeLatest: true
tag: production-${{ env.timestamp }}
name: Website production version ${{ env.timestamp }}
body: Website production version ${{ env.timestamp }}
2023-06-14 11:39:36 +02:00
artifacts: release-production-${{ env.timestamp }}.zip
2023-06-13 23:23:43 +02:00
token: ${{ secrets.GITHUB_TOKEN }}