Skip to content

Bump actions/upload-artifact from 3.1.0 to 3.1.2 #38

Bump actions/upload-artifact from 3.1.0 to 3.1.2

Bump actions/upload-artifact from 3.1.0 to 3.1.2 #38

Workflow file for this run

name: Azure Static Web Apps CI/CD
# This GitHub Action workflow triggers in two scenarios -
# 1. When a push is made to the main branch
# 2. When a pull request is either opened, synchronized, reopened,
# or closed, and the target is the main branch. If the change
# is just to the podcast_audio file, then it is ignored.
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
workflow_dispatch:
# The workflow has several phases. Phases 1, 2 and 3 run on a push, or if the pull request activity
# type is not 'closed'.
#
# 1. A validation phase, which is split into two separate jobs that run in parallel.
# 1.1 A set of steps that compress images
# 1.2 A set of steps that lint the markdown contents of the website
#
# 2. Build the Static Website by using the Hugo CLI.
#
# 3. Deploy the website to Azure Static Web Apps
# 3.1 If the workflow was triggered by a pull request (not a closed activity), then publish the static assets
# to the static web app. This is associated with the GitHub Actions staging.azure environment.
# 3.2 If the workflow was triggered by a push to main, then publish the static assets to the static
# web app. This is associated with the GitHub Actions production.azure environment, so requires manual approval.
#
# 4 If the workflow was triggered by a Pull Request close event, then close the staging sites which are open.
# Environment variables used for consistency across the workflow.
env:
HUGO_VERSION: '0.96.0'
SWA_NAME: 'cwc-presentation'
AZURE_CLI_VERSION: '2.34.1'
jobs:
# A set of steps used to compress the images, making sure that images are compressed ahead of publishing to the site.
# This is done to make sure that the browsing experience remains speedy.
compressor:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: CloudWithChris/Reusable-Workflows/.github/workflows/compress-images.yaml@main
with:
friendly_environment: Compress
secrets:
githubtoken: ${{ secrets.GITHUB_TOKEN }}
# A set of steps used to render the website from the markdown, theme and assets into the HTML, CSS, JS and images that are delivered to a user.
build:
if: github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'closed')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: 'Setup Hugo on Runner'
uses: peaceiris/actions-hugo@v2
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: 'Build and Minify Hugo Contents'
run: hugo --minify --baseURL 'https://presentations.cloudwithchris.com'
if: ${{ github.ref == 'refs/heads/main' }}
- name: 'Build and Minify Hugo Contents'
run: hugo --minify
if: ${{ github.ref != 'refs/heads/main' }}
- name: 'Zip the artifact'
run: |
cd "${{ github.workspace }}"
zip -r website.zip public
- name: 'Upload Generated Static Content as Website Artifact'
uses: actions/[email protected]
with:
name: website_zip
path: ${{ github.workspace }}/website.zip
deploy_preview:
if: (github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'closed')
needs: [compressor, build]
permissions:
id-token: write
contents: read
pull-requests: write
uses: CloudWithChris/Reusable-Workflows/.github/workflows/azure-staticwebapp-deploy.yaml@main
with:
friendly_environment: Preview
github_environment: staging.azure
swa_name: cwc-presentation
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
githubtoken: ${{ secrets.GITHUB_TOKEN }}
prod:
if: github.event_name == 'push' || github.event_name == 'schedule'
needs: [build]
permissions:
id-token: write
contents: read
uses: CloudWithChris/Reusable-Workflows/.github/workflows/azure-staticwebapp-deploy.yaml@main
with:
friendly_environment: Prod
github_environment: production.azure
swa_name: cwc-presentation
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
githubtoken: ${{ secrets.GITHUB_TOKEN }}
close_pull_request_job:
if: github.event.pull_request.head.repo.full_name == github.repository && github.event.action == 'closed'
permissions:
id-token: write
contents: read
uses: CloudWithChris/Reusable-Workflows/.github/workflows/azure-staticwebapp-close-pr.yaml@main
with:
friendly_environment: Preview
github_environment: preview.azure
swa_name: cwc-presentation
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}