Add Staging Environment (#131) #1331
This file contains hidden or 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: GitHub Pages | |
on: | |
push: | |
jobs: | |
# BUILD | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: '0.148.1' | |
extended: true | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
registry-url: 'https://npm.fontawesome.com/' | |
- name: NPM install | |
run: | | |
npm config set "@awesome.me:registry" https://npm.fontawesome.com/ | |
npm ci --ignore-scripts | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.FONTAWESOME_AUTH_TOKEN }} | |
- name: Build production | |
run: hugo --minify --destination public/prod | |
- name: Build staging | |
run: hugo --baseURL=https://staging.cryptomator.org/ --environment=staging --minify --destination public/staging | |
- name: Add robots.txt for staging | |
run: 'echo -e "User-agent: *\nDisallow: /" > public/staging/robots.txt' | |
- name: Upload Prod Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: prod-site | |
path: ./public/prod | |
- name: Upload Staging artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: staging-site | |
path: ./public/staging | |
# DEPLOY PROD | |
deploy-prod: | |
if: github.ref == 'refs/heads/main' | |
name: Deploy Prod to GitHub Pages | |
runs-on: ubuntu-latest | |
needs: [build] | |
permissions: # Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action | |
with: | |
artifact_name: prod-site | |
environment: # Deploy to the github-pages environment | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# DEPLOY STAGING | |
deploy-staging: | |
if: github.ref == 'refs/heads/develop' | |
name: Deploy Staging to GitHub Pages | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Download build | |
uses: actions/download-artifact@v4 | |
with: | |
name: staging-site | |
path: ./public | |
- name: Deploy to Staging Repository | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
personal_token: ${{ secrets.CRYPTOBOT_DEPLOY_STAGING_WEBSITE }} | |
external_repository: cryptomator/staging.cryptomator.org | |
publish_dir: ./public | |
publish_branch: main | |
cname: staging.cryptomator.org | |