Skip to content

Use release 2024.48.0 of design system and React components #9022

Use release 2024.48.0 of design system and React components

Use release 2024.48.0 of design system and React components #9022

Workflow file for this run

on:
pull_request:
types: [ opened, synchronize, reopened, closed, edited ]
name: Lagoon integration
env:
LAGOON_ENVIRONMENT: "pr-${{github.event.number}}"
GH_TOKEN: ${{ secrets.GH_DEPLOYMENT_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
jobs:
BranchNameLength:
name: Check branch length
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ensure branch name length
uses: lekterable/[email protected]
if: github.ref_type == 'branch' || github.ref_type == 'pull_request'
with:
allowed: |
/^.{1,100}$/
errorMessage: 'Branch name too long. This cannot be deployed to Lagoon.'
# Creating the deployment that Lagoon will look for, and add status to.
CreateDeployment:
name: Create deployment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
needs: [BranchNameLength]
steps:
- run: |
LAGOON_DEPLOYS_LOG_URL=$(echo "https://ui.lagoon.dplplat01.dpl.reload.dk/projects/dpl-cms/dpl-cms-${{ env.LAGOON_ENVIRONMENT }}/deployments")
DEPLOYMENT_ID=$(echo '{
"ref": "${{ github.head_ref || github.ref_name }}",
"environment": "${{ env.LAGOON_ENVIRONMENT }}",
"auto_merge": false,
"required_contexts": []
}' | gh api --method POST "/repos/${{ env.OWNER }}/${{ env.REPO }}/deployments" --input - --jq '.id')
gh api --method POST "/repos/${{ env.OWNER }}/${{ env.REPO }}/deployments/$DEPLOYMENT_ID/statuses" \
-f "state=in_progress" -f "log_url=$LAGOON_DEPLOYS_LOG_URL"
echo "deployment_id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
# When we close the pull request, we want to set the environment as inactive.
CloseEnvironment:
name: Close environment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
needs: [BranchNameLength]
steps:
- run: gh api --method DELETE "/repos/${{ env.OWNER }}/${{ env.REPO }}/environments/${{ env.LAGOON_ENVIRONMENT }}"
# We only permit the integration with Lagoon to run if the user is
# authorized. This saves on resources and ensures we only spin up sites for
# legitimate contributions.
# The integration is controlled by creating synthetic events related to select
# pull-request events, and send them to Lagoon.
InformLagoon:
name: Send synthetic event to Lagoon
runs-on: ubuntu-latest
needs: [BranchNameLength]
steps:
- name: Send pull request event
uses: distributhor/workflow-webhook@v3
env:
webhook_url: ${{ secrets.LAGOON_WEBHOOK_URL }}
webhook_secret: ${{ secrets.LAGOON_WEBHOOK_SECRET }}
webhook_type: 'json-extended'