Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/workflows/deploy-laravel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Reusable RASGO deploy, Laravel on Ploi (RINF-54, WFA-01.1, D-104): reads rasgo.deploy.yml, asks RASGO Core with
# deploy-start, calls the Ploi deploy webhook of the site, waits until /version answers with this commit and closes
# the deploy in Core with deploy-finish. Production only deploys with an approval_id that Core confirms.
# Also deploys rasgo-core (adapter monorepo-ploi): one Ploi site per environment.
# Usage in each repository (.github/workflows/deploy.yml), with the secrets in its staging and production environments:
#
# name: Deploy
# on:
# push:
# branches: [main]
# workflow_dispatch:
# inputs:
# environment: { type: choice, options: [production, staging], default: production }
# approval_id: { type: string, required: false }
# rollback_of: { type: string, required: false }
# task: { type: string, required: false }
# jobs:
# deploy:
# uses: rasgo-studio/.github/.github/workflows/deploy-laravel.yml@main
# with:
# environment: ${{ inputs.environment || 'staging' }}
# approval_id: ${{ inputs.approval_id }}
# rollback_of: ${{ inputs.rollback_of }}
# task: ${{ inputs.task }}
# secrets: inherit
#
name: Deploy

on:
workflow_call:
inputs:
environment:
description: staging or production, as in rasgo.deploy.yml
type: string
required: true
approval_id:
description: Approval of Core for this commit (production, and any environment with approval core)
type: string
default: ""
rollback_of:
description: deployment_id of the failed deploy that this one undoes (Core allows it without a new approval)
type: string
default: ""
task:
description: Plane task code (ACME01WEB-23), so Core can report the result on it
type: string
default: ""
app:
description: App name in Core, when it is not the component of the contract
type: string
default: ""
version:
description: Version to record in Core; by default the number of the tag, or the short commit
type: string
default: ""
versions:
description: JSON object with the version of each app (a monorepo such as rasgo-core)
type: string
default: ""
ploi-branch:
description: Branch the Ploi site pulls, when the environment deploys a tag
type: string
default: main
secrets:
RASGO_CORE_DEPLOY_TOKEN:
description: Core token of the deploy actor (ops 1)
required: false
PLOI_DEPLOY_WEBHOOK:
description: Deploy webhook of the Ploi site of this environment
required: false

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
# The secrets come from this environment of the calling repository (DEV-07).
environment: ${{ inputs.environment }}
concurrency:
group: deploy-${{ github.repository }}-${{ inputs.environment }}
cancel-in-progress: false
env:
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
DEPLOY_ADAPTERS: laravel-ploi monorepo-ploi
APPROVAL_ID: ${{ inputs.approval_id }}
ROLLBACK_OF: ${{ inputs.rollback_of }}
TASK: ${{ inputs.task }}
APP: ${{ inputs.app }}
VERSION: ${{ inputs.version }}
VERSIONS: ${{ inputs.versions }}
PLOI_BRANCH: ${{ inputs.ploi-branch }}
CORE_URL: ${{ vars.RASGO_CORE_URL || 'https://api.rasgo.studio' }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: rasgo.deploy.yml
sparse-checkout-cone-mode: false
- name: Contract
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: contract
- name: Secrets
uses: rasgo-studio/.github/actions/deploy-core@main
env:
RASGO_CORE_DEPLOY_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
PLOI_DEPLOY_WEBHOOK: ${{ secrets.PLOI_DEPLOY_WEBHOOK }}
with:
command: require
args: RASGO_CORE_DEPLOY_TOKEN PLOI_DEPLOY_WEBHOOK
# Ploi pulls the head of its branch, not a commit: only that head can be the approved commit.
- name: Branch the server pulls
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: branch-head
- name: Start (Core checks the approval)
uses: rasgo-studio/.github/actions/deploy-core@main
env:
CORE_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
with:
command: start
- name: Deploy (Ploi)
env:
WEBHOOK: ${{ secrets.PLOI_DEPLOY_WEBHOOK }}
run: |
curl -fsS -X POST --max-time 30 -o /dev/null "$WEBHOOK"
echo "Despliegue pedido a Ploi."
- name: Health
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: health
- name: Finish (record in Core)
if: always()
uses: rasgo-studio/.github/actions/deploy-core@main
env:
CORE_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
with:
command: finish
170 changes: 170 additions & 0 deletions .github/workflows/deploy-static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Reusable RASGO deploy, static site on Cloudflare Pages (RINF-54, WFA-01.1, D-104): reads rasgo.deploy.yml, builds
# this commit, asks RASGO Core with deploy-start, uploads the build with wrangler (Direct Upload), waits until the
# health path answers with this commit and closes the deploy in Core with deploy-finish. Production only deploys
# with an approval_id that Core confirms. The build gets a version.json (component, version, commit) unless it has one.
# The Pages project is a Direct Upload project: its Git integration, if any, does not deploy production by itself.
# Usage in each repository (.github/workflows/deploy.yml), with the secrets in its staging and production environments:
#
# name: Deploy
# on:
# push:
# branches: [main]
# workflow_dispatch:
# inputs:
# environment: { type: choice, options: [production, staging], default: production }
# approval_id: { type: string, required: false }
# rollback_of: { type: string, required: false }
# task: { type: string, required: false }
# jobs:
# deploy:
# uses: rasgo-studio/.github/.github/workflows/deploy-static.yml@main
# with:
# environment: ${{ inputs.environment || 'staging' }}
# approval_id: ${{ inputs.approval_id }}
# rollback_of: ${{ inputs.rollback_of }}
# task: ${{ inputs.task }}
# pages-project: example-org
# secrets: inherit
#
name: Deploy

on:
workflow_call:
inputs:
environment:
description: staging or production, as in rasgo.deploy.yml
type: string
required: true
approval_id:
description: Approval of Core for this commit (production, and any environment with approval core)
type: string
default: ""
rollback_of:
description: deployment_id of the failed deploy that this one undoes (Core allows it without a new approval)
type: string
default: ""
task:
description: Plane task code (ACME01WEB-23), so Core can report the result on it
type: string
default: ""
app:
description: App name in Core, when it is not the component of the contract
type: string
default: ""
version:
description: Version to record in Core; by default the number of the tag, or the short commit
type: string
default: ""
pages-project:
description: Name of the Cloudflare Pages project
type: string
required: true
production-branch:
description: Production branch of the Pages project
type: string
default: main
staging-branch:
description: Pages branch (preview alias) that serves staging
type: string
default: staging
build-command:
description: Command that builds the site (Nuxt by default, as ci-static.yml)
type: string
default: npm ci && npm run generate
output-dir:
description: Folder the build publishes
type: string
default: .output/public
node-version:
type: string
default: "22"
wrangler-version:
description: Exact version of wrangler, the Cloudflare CLI that uploads the build
type: string
default: 4.151.0
secrets:
RASGO_CORE_DEPLOY_TOKEN:
description: Core token of the deploy actor (ops 1)
required: false
CLOUDFLARE_API_TOKEN:
description: Cloudflare token with Pages edit on the account
required: false
CLOUDFLARE_ACCOUNT_ID:
description: Cloudflare account of the Pages project
required: false

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
# The secrets come from this environment of the calling repository (DEV-07).
environment: ${{ inputs.environment }}
concurrency:
group: deploy-${{ github.repository }}-${{ inputs.environment }}
cancel-in-progress: false
env:
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
DEPLOY_ADAPTERS: static
APPROVAL_ID: ${{ inputs.approval_id }}
ROLLBACK_OF: ${{ inputs.rollback_of }}
TASK: ${{ inputs.task }}
APP: ${{ inputs.app }}
VERSION: ${{ inputs.version }}
CORE_URL: ${{ vars.RASGO_CORE_URL || 'https://api.rasgo.studio' }}
OUTPUT_DIR: ${{ inputs.output-dir }}
steps:
- uses: actions/checkout@v4
- name: Contract
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: contract
- name: Secrets
uses: rasgo-studio/.github/actions/deploy-core@main
env:
RASGO_CORE_DEPLOY_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
with:
command: require
args: RASGO_CORE_DEPLOY_TOKEN CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID
# The build comes before deploy-start, so a broken build does not spend the approval.
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- name: Build
env:
BUILD_COMMAND: ${{ inputs.build-command }}
run: bash -euo pipefail -c "$BUILD_COMMAND"
- name: Version file
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: version-file
- name: Start (Core checks the approval)
uses: rasgo-studio/.github/actions/deploy-core@main
env:
CORE_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
with:
command: start
- name: Deploy (Cloudflare Pages)
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
PAGES_PROJECT: ${{ inputs.pages-project }}
PAGES_BRANCH: ${{ inputs.environment == 'production' && inputs.production-branch || inputs.staging-branch }}
WRANGLER_VERSION: ${{ inputs.wrangler-version }}
run: |
npx --yes "wrangler@${WRANGLER_VERSION}" pages deploy "$OUTPUT_DIR" --project-name="$PAGES_PROJECT" \
--branch="$PAGES_BRANCH" --commit-hash="$GITHUB_SHA" --commit-dirty=true
- name: Health
uses: rasgo-studio/.github/actions/deploy-core@main
with:
command: health
- name: Finish (record in Core)
if: always()
uses: rasgo-studio/.github/actions/deploy-core@main
env:
CORE_TOKEN: ${{ secrets.RASGO_CORE_DEPLOY_TOKEN }}
with:
command: finish
Loading
Loading