Skip to content

Optimizing GH actions, to use less minutes. (WIP) #8251

Optimizing GH actions, to use less minutes. (WIP)

Optimizing GH actions, to use less minutes. (WIP) #8251

Workflow file for this run

on:
pull_request:
types: [ opened, synchronize, reopened, closed, edited ]
name: Lagoon integration
env:
LAGOON_HOST: "dplplat01.dpl.reload.dk"
LAGOON_PROJECT: "dpl-cms"
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.'
CloseEnvironment:
name: Close environment
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
permissions:
# Give the default GITHUB_TOKEN permission to close deployments.
deployments: write
steps:
- name: Generate environment data
id: environment
run: |
echo ::set-output name=id::pr-${{github.event.number}}
- name: Close environment
uses: bobheadxi/[email protected]
with:
step: deactivate-env
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ steps.environment.outputs.id }}
debug: ${{ runner.debug && 'true' || 'false' }}
# 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'