Website Deployment #96
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: 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 [email protected] | |
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 | |