Skip to content

Website Deployment

Website Deployment #85

Workflow file for this run

name: Autonomous deployment
run-name: Website Deployment
on:
push:
branches:
- main
jobs:
# Build the website and cache it >> https://docs.astro.build/de/reference/cli-reference/#astro-build
website-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Installing Astro
run: npm install astro
- name: Testing Website
run: npm run astro check
- name: Building Website
run: npm run build
- name: Get Date
id: get-date
run: echo "date=$(/bin/date -u "+%s")" >> $GITHUB_OUTPUT
shell: bash
- name: Creating Tarball
run: tar cfvz build.tar.gz ./dist
- name: Write2Cache
uses: actions/cache/save@v3
env:
cache-name: website-build
with:
path: build.tar.gz
key: build-cache-${{steps.get-date.outputs.date}}
beta-deploy:
runs-on: ubuntu-latest
needs: website-build
steps:
- name: Checkout Deploy
uses: actions/checkout@v3
with:
ref: beta
- name: Remove old Website from Cache
run: rm -rf *
- name: Restore Website from Cache
uses: actions/cache/restore@v3
env:
cache-name: website-build
with:
path: build.tar.gz
key: build-cache-${{steps.get-date.outputs.date}}
- name: Unpack tarball
run: tar -xf build.tar.gz
- name: Push to Deploy Branch
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Automated Build"
git push
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_branch: master