Skip to content

Instantly share code, notes, and snippets.

@olich97
Last active November 24, 2021 10:03
Show Gist options
  • Save olich97/a1fb2750a3ca07015ddb8e01685b7b7c to your computer and use it in GitHub Desktop.
Save olich97/a1fb2750a3ca07015ddb8e01685b7b7c to your computer and use it in GitHub Desktop.
name: deploy-preview
# Controls when the action will run. Triggers the workflow on push
# events but only for the develop branch
on:
push:
branches: [ develop ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "deploy-preview"
deploy-preview:
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE with submodules
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
# Initiate deployment status
- name: Start Deployment
uses: bobheadxi/deployments@v0.4.3
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Preview
# Install Hugo (specific version)
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.89.0'
extended: true
# Builds the site using Hugo
- name: Build
run: hugo --gc --minify --config=config.toml
# Push our generated Hugo site to Vercel
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
id: vercel-action
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
#github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} #Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} #Required
github-comment: false
working-directory: public
# Update deployment status
- name: Update Deployment Status
uses: bobheadxi/deployments@v0.4.3
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel-action.outputs.preview-url }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment