feat: Carvel Package the easy way #125
Workflow file for this run
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: wrangler.yaml | |
# Description: | |
# A Workflow that builds a static website using | |
# Hugo before publishing to Cloudflare Workers | |
# with the Wrangler CLI | |
################################################## | |
name: Wrangler | |
on: | |
# Automatically run anytime there | |
# is a push to the default branch | |
push: | |
branches: | |
- trunk | |
# Automatically run anytime a PR | |
# targets the default branch | |
# for the defined types. | |
pull_request: | |
branches: | |
- trunk | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- review_requested | |
permissions: | |
contents: read | |
pull-requests: write | |
checks: read | |
statuses: read | |
defaults: | |
run: | |
shell: bash | |
env: | |
HUGO_VERSION: 0.111.3 | |
WRANGLER_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_TOKEN }} | |
BRANCH_NAME_CURRENT: ${{ github.head_ref || github.ref_name }} | |
BRANCH_NAME_DEFAULT: ${{ github.event.repository.default_branch }} | |
jobs: | |
################################################## | |
# Publish to Cloudflare Workers using the Wrangler CLI | |
################################################## | |
deploy: | |
name: Publish website | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: true | |
matrix: | |
os: | |
- ubuntu-latest | |
steps: | |
- id: checkout_repository | |
name: Checkout repository with submodules | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
clean: true | |
persist-credentials: true | |
- id: hugo_install | |
name: Download and Install Hugo | |
run: | | |
wget https://github.com/gohugoio/hugo/releases/download/v${{ env.HUGO_VERSION }}/hugo_extended_${{ env.HUGO_VERSION }}_linux-amd64.deb | |
sudo dpkg -i hugo_extended_${{ env.HUGO_VERSION }}_linux-amd64.deb | |
hugo version | |
- id: hugo_cleanup | |
name: Remove unwanted Hugo files before build | |
run: | | |
rm -f themes/*/content/post/* || echo "Failed to remove posts from theme" | |
rm -f themes/*/data/authors/* || echo "Failed to remove authors from theme" | |
rm -rf themes/*/exampleSite || echo "Failed to remove exampleSite from theme" | |
rm -rf assets/images/backup || echo "Failed to remove extra images" | |
rm -rf static/images/backup || echo "Failed to remove extra images" | |
- id: hugo_modules | |
name: Download Hugo modules | |
run: | | |
if [[ -f package.json ]]; then | |
echo "Running npm install" | |
npm install | |
fi | |
if [[ -f "go.mod" ]]; then | |
echo "Downloading Go modules" | |
go mod download -x | |
else | |
echo "No go.mod file found" | |
fi | |
echo "Downloading Hugo modules" | |
hugo mod clean | |
hugo mod tidy | |
hugo mod graph | |
# Any branch other than the default is staged for preview. | |
- id: hugo_build_staging | |
name: Build the website using Hugo (Staging) | |
if: env.BRANCH_NAME_CURRENT != env.BRANCH_NAME_DEFAULT | |
env: | |
TZ: "Australia/Sydney" | |
run: | | |
hugo --verbose --gc --minify --cleanDestinationDir --environment staging | |
touch public/.nojekyll | |
ls -la public/ | |
# The default branch is 'Production' | |
- id: hugo_build_production | |
if: env.BRANCH_NAME_CURRENT == env.BRANCH_NAME_DEFAULT | |
name: Build the website using Hugo (Production) | |
env: | |
TZ: "Australia/Sydney" | |
run: | | |
hugo --verbose --gc --minify --cleanDestinationDir --environment production | |
touch public/.nojekyll | |
ls -la public/ | |
- id: publish_website_staging | |
name: Publish website using Wrangler (Staging) | |
if: | | |
env.BRANCH_NAME_CURRENT != env.BRANCH_NAME_DEFAULT && | |
steps.hugo_build_staging.outcome == 'success' | |
uses: cloudflare/[email protected] | |
with: | |
environment: staging | |
apiToken: ${{ env.WRANGLER_API_TOKEN }} | |
preCommands: | | |
npm --prefix workers-site install | |
command: deploy --env staging | |
# Only 'trunk' branch is pushed to the Production website | |
- id: publish_website_production | |
name: Publish website using Wrangler (Production) | |
if: | | |
env.BRANCH_NAME_CURRENT == env.BRANCH_NAME_DEFAULT && | |
steps.hugo_build_production.outcome == 'success' | |
uses: cloudflare/[email protected] | |
with: | |
environment: production | |
apiToken: ${{ env.WRANGLER_API_TOKEN }} | |
preCommands: | | |
npm --prefix workers-site install | |
command: deploy --env production | |
################################################## | |
# Giphy thumbs up or down | |
################################################## | |
check: | |
name: PR Status Checks | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: true | |
matrix: | |
os: | |
- ubuntu-latest | |
needs: deploy | |
steps: | |
- name: PR Status Giphy | |
id: pr-status-giphy | |
uses: dgteixeira/pr-status-giphy-action@v2 | |
if: github.event_name == 'pull_request' | |
env: | |
GIPHY_API_KEY: ${{ secrets.GIPHY_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |