Manually rebuild and deploy static site #93
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: Manually rebuild and deploy the static site | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment' | |
required: true | |
type: choice | |
options: | |
- test | |
- stage | |
- prod | |
default: 'test' | |
concurrency: | |
group: deploy-${{ github.event.inputs.environment }} | |
cancel-in-progress: true | |
jobs: | |
nuxt-deploy: | |
name: Static Generation build | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/workflows/setup-workspace | |
- name: Cache built static site | |
uses: actions/cache@v3 | |
with: | |
path: ./dist | |
key: nuxt-site-${{ github.sha }} | |
- name: Sets env vars for test | |
run: | | |
echo "CRAFT_ENDPOINT=${{secrets.CRAFT_ENDPOINT}} " >> $GITHUB_ENV | |
echo "SITEMAP_HOST=${{secrets.SITEMAP_URL_TEST}}" >> $GITHUB_ENV | |
echo "NETLIFY_SITE_ID=${{secrets.NETLIFY_SITE_ID}}" >> $GITHUB_ENV | |
echo "ES_READ_KEY=${{secrets.ES_READ_KEY_TEST}}" >> $GITHUB_ENV | |
echo "ES_WRITE_KEY=${{secrets.ES_WRITE_KEY_TEST}}" >> $GITHUB_ENV | |
echo "ES_INDEX=${{secrets.ES_INDEX_TEST}}" >> $GITHUB_ENV | |
echo "ES_INDEX_PREFIX=${{secrets.ES_INDEX_PREFIX_TEST}}" >> $GITHUB_ENV | |
echo "LIBGUIDES_ES_INDEX=${{secrets.LIBGUIDES_ES_INDEX_TEST}}" >> $GITHUB_ENV | |
echo "ES_TEMP_INDEX_PREFIX_LIBGUIDES=${{secrets.ES_TEMP_INDEX_PREFIX_LIBGUIDES_TEST}}" >> $GITHUB_ENV | |
if: github.event.inputs.environment == 'test' | |
- name: Sets env vars for stage | |
run: | | |
echo "CRAFT_ENDPOINT=${{secrets.CRAFT_STAGE_ENDPOINT}}" >> $GITHUB_ENV | |
echo "SITEMAP_HOST=${{secrets.SITEMAP_URL_STAGE}}" >> $GITHUB_ENV | |
echo "NETLIFY_SITE_ID=${{secrets.NETLIFY_STAGE_LIBRARY_SITE_ID}}" >> $GITHUB_ENV | |
echo "ES_READ_KEY=${{secrets.ES_READ_KEY_STAGE}}" >> $GITHUB_ENV | |
echo "ES_WRITE_KEY=${{secrets.ES_WRITE_KEY_STAGE}}" >> $GITHUB_ENV | |
echo "ES_INDEX=${{secrets.ES_INDEX_STAGE}}" >> $GITHUB_ENV | |
echo "ES_INDEX_PREFIX=${{secrets.ES_INDEX_PREFIX_STAGE}}" >> $GITHUB_ENV | |
echo "LIBGUIDES_ES_INDEX=${{secrets.LIBGUIDES_ES_INDEX_STAGE}}" >> $GITHUB_ENV | |
echo "ES_TEMP_INDEX_PREFIX_LIBGUIDES=${{secrets.ES_TEMP_INDEX_PREFIX_LIBGUIDES_STAGE}}" >> $GITHUB_ENV | |
if: github.event.inputs.environment == 'stage' | |
- name: Sets env vars for prod | |
run: | | |
echo "CRAFT_ENDPOINT=${{secrets.CRAFT_PROD_ENDPOINT}}" >> $GITHUB_ENV | |
echo "SITEMAP_HOST=${{secrets.SITEMAP_URL_PROD}}" >> $GITHUB_ENV | |
echo "NETLIFY_SITE_ID=${{secrets.NETLIFY_PROD_LIBRARY_SITE_ID}}" >> $GITHUB_ENV | |
echo "ES_READ_KEY=${{secrets.ES_READ_KEY_PROD}}" >> $GITHUB_ENV | |
echo "ES_WRITE_KEY=${{secrets.ES_WRITE_KEY_PROD}}" >> $GITHUB_ENV | |
echo "ES_INDEX=${{secrets.ES_INDEX_PROD}}" >> $GITHUB_ENV | |
echo "ES_INDEX_PREFIX=${{secrets.ES_INDEX_PREFIX_PROD}}" >> $GITHUB_ENV | |
echo "LIBGUIDES_ES_INDEX=${{secrets.LIBGUIDES_ES_INDEX_PROD}}" >> $GITHUB_ENV | |
echo "ES_TEMP_INDEX_PREFIX_LIBGUIDES=${{secrets.ES_TEMP_INDEX_PREFIX_LIBGUIDES_PROD}}" >> $GITHUB_ENV | |
if: github.event.inputs.environment == 'prod' | |
- run: npm run generate | |
env: | |
CRAFT_ENDPOINT: ${{env.CRAFT_ENDPOINT}} | |
S3_BUCKET: "https://static.library.ucla.edu/" | |
SITEMAP_HOST: ${{env.SITEMAP_HOST}} | |
ES_URL: ${{ secrets.ES_URL }} | |
ESApiKey: ${{ secrets.ESApiKey }} | |
LIBCAL_ENDPOINT: ${{ secrets.LIBCAL_ENDPOINT }} | |
ES_READ_KEY: ${{env.ES_READ_KEY}} | |
ES_WRITE_KEY: ${{env.ES_WRITE_KEY}} | |
ES_INDEX: ${{env.ES_INDEX}} | |
ES_INDEX_PREFIX: ${{env.ES_INDEX_PREFIX}} | |
ES_TEMP_INDEX_PREFIX_LIBGUIDES: ${{secrets.ES_TEMP_INDEX_PREFIX_LIBGUIDES}} | |
LIBGUIDES_ES_INDEX: ${{env.LIBGUIDES_ES_INDEX}} | |
- name: Deploy to Netlify | |
uses: nwtgck/actions-netlify@v2 # | |
with: | |
production-deploy: true | |
deploy-message: https://github.com/UCLALibrary/meap-website-nuxt/commit/${{ github.sha }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
publish-dir: "./dist" | |
fails-without-credentials: true | |
github-deployment-environment: production | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }} |