Deploy Website #3767
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: Deploy Website | |
on: | |
# run everyday at 12:15 utf ( 8:15 am est) to roll out new posts | |
schedule: | |
- cron: '15 12 * * *' | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: [ main ] | |
jobs: | |
build-website: | |
name: Build Website | |
runs-on: [earthly-satellite#gha-website] | |
if: > | |
github.event_name != 'pull_request' || | |
!contains(github.event.pull_request.title, '[AUTO-PR]') | |
steps: | |
- uses: FranzDiebold/github-env-vars-action@v2 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build Site | |
uses: mathiasvr/command-output@v1 | |
id: build-site | |
env: | |
FORCE_COLOR: 1 | |
EARTHLY_INSTALL_ID: "earthly-website-githubactions" | |
EARTHLY_TOKEN: ${{ secrets.EARTHLY_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_STAGING_SITE_ID: ${{ secrets.NETLIFY_STAGING_SITE_ID }} | |
NETLIFY_STAGING_AUTH_TOKEN: ${{ secrets.NETLIFY_STAGING_AUTH_TOKEN }} | |
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} | |
with: | |
run: |- | |
echo "Build and publish website" | |
if [ "$CI_ACTION_REF_NAME" == "main" ]; then | |
echo "Main Build - going to prod!" | |
earthly \ | |
--secret NETLIFY_SITE_ID="$NETLIFY_SITE_ID" \ | |
--secret NETLIFY_AUTH_TOKEN="$NETLIFY_AUTH_TOKEN" \ | |
--secret YOUTUBE_API_KEY="$YOUTUBE_API_KEY" \ | |
--build-arg DESTINATION="PROD" \ | |
--build-arg DATE="$(date +"%Y%m%d%H%M%S")" \ | |
--build-arg CACHE_IMAGE="YES" \ | |
+publish 2>&1 | |
else | |
echo "Branch Build - only for preview" | |
earthly \ | |
--secret NETLIFY_STAGING_SITE_ID="$NETLIFY_STAGING_SITE_ID" \ | |
--secret NETLIFY_STAGING_AUTH_TOKEN="$NETLIFY_STAGING_AUTH_TOKEN" \ | |
--secret YOUTUBE_API_KEY="$YOUTUBE_API_KEY" \ | |
--build-arg DATE="$(date +"%Y%m%d%H%M%S")" \ | |
--build-arg CACHE_IMAGE="YES" \ | |
+publish 2>&1 | |
fi | |
- name: match | |
continue-on-error: true | |
uses: actions-ecosystem/action-regex-match@v2 | |
id: regex-match | |
with: | |
text: ${{ steps.build-site.outputs.stdout }} | |
regex: 'https.*netlify.app' | |
- name: Comment on build | |
run: |- | |
echo "Preview URL: ${{ steps.regex-match.outputs.match }}" >> $GITHUB_STEP_SUMMARY | |