Skip to content

Update astro monorepo (#30) #83

Update astro monorepo (#30)

Update astro monorepo (#30) #83

Workflow file for this run

name: Website Deployment
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
outputs:
skip: ${{ steps.moon-build.outputs.skip }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- id: moon-build
run: |
temp_file=$(mktemp)
moon --color --log info ci site:build | tee "$temp_file"
if grep -q "No targets to run based on touched files" "$temp_file"; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
rm "$temp_file"
env:
ASTRO_STUDIO_APP_TOKEN: ${{ secrets.ASTRO_STUDIO_APP_TOKEN }}
# MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }}
- uses: moonrepo/run-report-action@49da5efa5e6f8afc564a14ad3686da3f77b45236 # v1.7.0
if: ${{ steps.moon-build.outputs.skip != 'true' }}
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ steps.moon-build.outputs.skip != 'true' }}
id: artifact-upload
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name: ${{ github.workflow_sha }}
# A file, directory or wildcard pattern that describes what to upload
# Required.
path: apps/site/dist/
# The desired behavior if no files are found using the provided path.
# Available Options:
# warn: Output a warning but do not fail the action
# error: Fail the action with an error message
# ignore: Do not output any warnings or errors, the action does not fail
# Optional. Default is 'warn'
if-no-files-found: warn
# Duration after which artifact will expire in days. 0 means using default retention.
# Minimum 1 day.
# Maximum 90 days unless changed from the repository settings page.
# Optional. Defaults to repository settings.
retention-days: 1
# The level of compression for Zlib to be applied to the artifact archive.
# The value can range from 0 to 9.
# For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
# Optional. Default is '6'
compression-level: 0
# If true, an artifact with a matching name will be deleted before a new one is uploaded.
# If false, the action will fail if an artifact for the given name already exists.
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite: true
deploy-preview:
needs: build
if: ${{ github.ref != 'refs/heads/main' && needs.build.outputs.skip != 'true' }}
name: Deploy - Preview
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: deployment
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/create-deployment.js')
await script({github, context, core})
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: ${{ github.workflow_sha}}
# Destination path. Supports basic tilde expansion.
# Optional. Default is $GITHUB_WORKSPACE
path: apps/site/dist/
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
# pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Optional. Default is 'false'
merge-multiple: true
# The GitHub token used to authenticate with the GitHub API.
# This is required when downloading artifacts from a different repository or from a different workflow run.
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
# github-token:
# The repository owner and the repository name joined together by "/".
# If github-token is specified, this is the repository that artifacts will be downloaded from.
# Optional. Default is ${{ github.repository }}
# repository:
# The id of the workflow run where the desired download artifact was uploaded from.
# If github-token is specified, this is the run that artifacts will be downloaded from.
# Optional. Default is ${{ github.run_id }}
# run-id:
- uses: cloudflare/wrangler-action@a84dcc6dd36c8769fbff7e622308c8050fc41f4f # v3.5.0
id: wrangler
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "3.34.2"
workingDirectory: "apps/site"
packageManager: pnpm
command: pages deploy dist --project-name astrolicious
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEPLOYMENT_ID: ${{ steps.deployment.outputs.deployment-id }}
DEPLOYMENT_URL: ${{ steps.wrangler.outputs.deployment-url }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/update-deployment.js')
await script({github, context, core})
deploy-production:
if: ${{ github.ref == 'refs/heads/main' && needs.build.outputs.skip != 'true' }}
needs: build
name: Deploy - Production
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: deployment
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/create-deployment.js')
await script({github, context, core})
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: ${{ github.workflow_sha}}
# Destination path. Supports basic tilde expansion.
# Optional. Default is $GITHUB_WORKSPACE
path: apps/site/dist/
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
# pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Optional. Default is 'false'
merge-multiple: true
# The GitHub token used to authenticate with the GitHub API.
# This is required when downloading artifacts from a different repository or from a different workflow run.
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
# github-token:
# The repository owner and the repository name joined together by "/".
# If github-token is specified, this is the repository that artifacts will be downloaded from.
# Optional. Default is ${{ github.repository }}
# repository:
# The id of the workflow run where the desired download artifact was uploaded from.
# If github-token is specified, this is the run that artifacts will be downloaded from.
# Optional. Default is ${{ github.run_id }}
# run-id:
- uses: cloudflare/wrangler-action@a84dcc6dd36c8769fbff7e622308c8050fc41f4f # v3.5.0
id: wrangler
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "3.34.2"
workingDirectory: "apps/site"
packageManager: pnpm
command: pages deploy dist --project-name astrolicious
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEPLOYMENT_ID: ${{ steps.deployment.outputs.deployment-id }}
DEPLOYMENT_URL: ${{ steps.wrangler.outputs.deployment-url }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/update-deployment.js')
await script({github, context, core})