-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: create Cloudflare deployments (#17)
Signed-off-by: Fernando Fernández <[email protected]>
- Loading branch information
Showing
9 changed files
with
386 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: GitHub CodeQL 🔬 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
commit: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze ${{ matrix.language }} 🔬 | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: | ||
- javascript-typescript | ||
|
||
steps: | ||
- name: Checkout repository ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.commit }} | ||
show-progress: false | ||
|
||
- name: Initialize CodeQL 🛠️ | ||
uses: github/codeql-action/[email protected] | ||
with: | ||
queries: security-and-quality | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Autobuild 📦 | ||
uses: github/codeql-action/[email protected] | ||
|
||
- name: Perform CodeQL Analysis 🧪 | ||
uses: github/codeql-action/[email protected] | ||
with: | ||
category: '/language:${{matrix.language}}' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Deploy 🏗️ | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch: | ||
required: true | ||
type: string | ||
commit: | ||
required: false | ||
type: string | ||
comment: | ||
required: false | ||
type: boolean | ||
artifact_name: | ||
required: false | ||
type: string | ||
default: github-pages | ||
is_prerelease: | ||
required: true | ||
type: boolean | ||
|
||
# Allow this job to clone the repo and create a page deployment | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
env: | ||
CF_PROJECT_NAME: bpm2025seville | ||
|
||
jobs: | ||
cf-pages: | ||
name: CloudFlare Pages 📃 | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ inputs.branch == 'main' && 'Production (Cloudflare Pages)' || 'Preview (Cloudflare Pages)' }} | ||
url: ${{ steps.cf.outputs.deployment-url }} | ||
outputs: | ||
url: ${{ steps.cf.outputs.deployment-url }} | ||
|
||
steps: | ||
- name: Download workflow artifact ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ inputs.artifact_name }} | ||
path: dist | ||
|
||
- name: Publish to Cloudflare Pages 📃 | ||
uses: cloudflare/[email protected] | ||
id: cf | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: pages deploy dist --project-name=${{ env.CF_PROJECT_NAME }} --branch=${{ inputs.branch }} | ||
|
||
github-pages: | ||
name: GitHub Pages 📃 | ||
runs-on: ubuntu-latest | ||
if: ${{ !inputs.is_prerelease }} | ||
environment: | ||
name: ${{ inputs.branch == 'main' && 'Production (GitHub Pages)' || 'Preview (GitHub Pages)' }} | ||
url: ${{ steps.deploy.outputs.page_url }} | ||
|
||
steps: | ||
- name: Deploy to GitHub Pages 🚀 | ||
id: deploy | ||
uses: actions/[email protected] | ||
|
||
compose-comment: | ||
name: Compose and push comment 📝 | ||
# Always run so the comment is composed for the workflow summary | ||
if: ${{ always() }} | ||
uses: ./.github/workflows/__job_messages.yml | ||
secrets: inherit | ||
needs: | ||
- cf-pages | ||
|
||
with: | ||
branch: ${{ inputs.branch }} | ||
commit: ${{ inputs.commit }} | ||
preview_url: ${{ needs.cf-pages.outputs.url }} | ||
in_progress: false | ||
comment: ${{ inputs.comment }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Job messages ⚙️ | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch: | ||
required: false | ||
type: string | ||
commit: | ||
required: true | ||
type: string | ||
preview_url: | ||
required: false | ||
type: string | ||
in_progress: | ||
required: true | ||
type: boolean | ||
comment: | ||
required: false | ||
type: boolean | ||
marker: | ||
description: Hidden marker to detect PR comments composed by the bot | ||
required: false | ||
type: string | ||
default: "CFPages-deployment" | ||
|
||
env: | ||
CF_PAGES_DEPLOYMENT_URL: https://bpm2025seville.pages.dev | ||
|
||
jobs: | ||
cf_pages_msg: | ||
name: CloudFlare Pages deployment 📃🚀 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Compose message 📃 | ||
if: ${{ always() }} | ||
id: compose | ||
env: | ||
COMMIT: ${{ inputs.commit }} | ||
PREVIEW_URL: ${{ inputs.preview_url != '' && (inputs.branch != 'main' && inputs.preview_url || format('{0} ({1})', env.CF_PAGES_DEPLOYMENT_URL, inputs.preview_url)) || 'Not available' }} | ||
DEPLOY_STATUS: ${{ inputs.in_progress && '🔄 Deploying...' || (inputs.preview_url != '' && '✅ Deployed!' || '❌ Failure. Check workflow logs for details') }} | ||
DEPLOYMENT_TYPE: ${{ inputs.branch != 'main' && '🔀 Preview' || '⚙️ Production' }} | ||
WORKFLOW_RUN: ${{ !inputs.in_progress && format('**[View build logs](https://github.com/{0}/actions/runs/{1})**', github.repository, github.run_id) || '' }} | ||
# EOF is needed for multiline environment variables in a GitHub Actions context | ||
run: | | ||
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "| **Latest commit** | <code>${COMMIT::7}</code> |" >> $GITHUB_STEP_SUMMARY | ||
echo "|------------------------- |:----------------------------: |" >> $GITHUB_STEP_SUMMARY | ||
echo "| **Status** | $DEPLOY_STATUS |" >> $GITHUB_STEP_SUMMARY | ||
echo "| **Preview URL** | $PREVIEW_URL |" >> $GITHUB_STEP_SUMMARY | ||
echo "| **Type** | $DEPLOYMENT_TYPE |" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "$WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY | ||
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY) | ||
echo "msg<<EOF" >> $GITHUB_ENV | ||
echo "$COMPOSED_MSG" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Push comment to Pull Request 🔼 | ||
uses: thollander/[email protected] | ||
if: ${{ inputs.comment && steps.compose.conclusion == 'success' }} | ||
with: | ||
message: ${{ env.msg }} | ||
comment_tag: ${{ inputs.marker }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Packaging 📦 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
commit: | ||
required: false | ||
type: string | ||
is_prerelease: | ||
required: true | ||
type: boolean | ||
|
||
env: | ||
SITE_URL: https://www.bpm2025seville.org/ | ||
BASE_URL: / | ||
|
||
jobs: | ||
build: | ||
name: Build 🏗️ | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
show-progress: false | ||
ref: ${{ inputs.commit || github.sha }} | ||
|
||
- name: Setup node environment ⚙️ | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
check-latest: true | ||
|
||
- name: Install dependencies 📦 | ||
run: npm ci --no-audit | ||
|
||
- name: Build 🏗️ | ||
env: | ||
STAGING: ${{ inputs.is_prerelease && 1 || 0 }} | ||
BASE_URL: ${{ env.BASE_URL }} | ||
SITE_URL: ${{ env.SITE_URL }} | ||
run: npm run build | ||
|
||
- name: Upload client artifact ⬆️💻 | ||
uses: actions/[email protected] | ||
with: | ||
compression-level: 0 | ||
name: github-pages | ||
path: dist |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: Quality checks 👌🧪 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
merge_group: | ||
workflow_call: | ||
inputs: | ||
commit: | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
|
||
jobs: | ||
dependency-review: | ||
|
@@ -16,6 +16,7 @@ jobs: | |
- name: Checkout Repository | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.commit }} | ||
show-progress: false | ||
|
||
- name: Scan | ||
|
@@ -28,28 +29,30 @@ jobs: | |
|
||
conventional_commits: | ||
name: Conventional commits check 💬 | ||
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} | ||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'merge_group' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.commit }} | ||
show-progress: false | ||
|
||
- name: Check if all commits comply with the specification | ||
uses: webiny/[email protected] | ||
|
||
no_merge_commits: | ||
name: No merge commits check 🚫 | ||
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} | ||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'merge_group' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
show-progress: false | ||
ref: ${{ inputs.commit }} | ||
fetch-depth: 0 | ||
|
||
- name: Check commits | ||
|
@@ -64,12 +67,12 @@ jobs: | |
command: | ||
- lint | ||
- check | ||
- build | ||
|
||
steps: | ||
- name: Checkout ⬇️ | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.commit }} | ||
show-progress: false | ||
|
||
- name: Setup node environment ⚙️ | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.