Url proxy endpoint featuring OpenAPI #8343
Workflow file for this run
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
on: | |
pull_request: | |
# We have two groups of jobs in this workflow that reacts on actions: | |
# | |
# 1. We update the status of a Github Deployment on: | |
# - opened | |
# - synchronize | |
# - reopened | |
# - closed | |
# | |
# 2. We forward all events to lagoon via InformLagoon | |
types: [ opened, synchronize, reopened, closed, edited ] | |
name: Lagoon integration | |
env: | |
LAGOON_HOST: "dplplat01.dpl.reload.dk" | |
LAGOON_PROJECT: "dpl-cms" | |
jobs: | |
CheckEnvironment: | |
name: Check environment | |
runs-on: ubuntu-latest | |
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }} | |
steps: | |
- name: Generate environment data | |
id: environment | |
run: | | |
echo ::set-output name=id::pr-${{github.event.number}} | |
echo ::set-output name=url::'https://varnish.pr-${{github.event.number}}.${{ env.LAGOON_PROJECT }}.${{ env.LAGOON_HOST }}/' | |
echo ::set-output name=logs::'https://ui.lagoon.${{ env.LAGOON_HOST }}/projects/${{ env.LAGOON_PROJECT }}/${{ env.LAGOON_PROJECT }}-pr-${{github.event.number}}/deployments' | |
- name: Start deployment | |
uses: bobheadxi/[email protected] | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: ${{ steps.environment.outputs.id }} | |
ref: ${{ github.head_ref }} | |
logs: ${{ steps.environment.outputs.logs }} | |
log_args: true | |
- name: Wait for environment to become available | |
uses: nev7n/wait_for_response@v1 | |
with: | |
url: ${{ steps.environment.outputs.url }} | |
responseCode: 200 | |
# Time in ms. Wait for 15 mins for deployment to complete. We have | |
# seen deployments taking up to 12 mins. | |
timeout: 600000 | |
# Poll every 10 seconds. For whatever reason Lagoon environments may | |
# return 200 during the deployment process even though the deployment | |
# is not complete. Reduce polling interval to the risk of this | |
# happening. | |
interval: 10000 | |
- name: Finish deployment | |
if: always() | |
uses: bobheadxi/[email protected] | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env_url: ${{ steps.environment.outputs.url }} | |
logs: ${{ steps.environment.outputs.logs }} | |
log_args: true | |
CloseEnvironment: | |
name: Close environment | |
runs-on: ubuntu-latest | |
if: ${{ github.event.action == 'closed' }} | |
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 }} | |
log_args: true | |
# 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. | |
# | |
# The job expects the following secrets: | |
# LAGOON_WEBHOOK_URL: The url events are to be delivered to | |
# LAGOON_WEBHOOK_SECRET: Shared lagoon webhook secret | |
# | |
InformLagoon: | |
name: Send synthetic event to Lagoon | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send pull request event | |
uses: distributhor/workflow-webhook@v2 | |
env: | |
webhook_url: ${{ secrets.LAGOON_WEBHOOK_URL }} | |
webhook_secret: ${{ secrets.LAGOON_WEBHOOK_SECRET }} | |
webhook_type: 'json-extended' |