# Triggers after the Build has finished, # because artifacts are not externally available # until the end of their workflow. name: Deploy develop.element.io concurrency: deploy_develop on: workflow_run: workflows: [ "Build" ] types: - completed jobs: deploy: runs-on: ubuntu-latest environment: deploy_develop if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' steps: - name: Find Artifact ID uses: actions/github-script@v3.1.0 id: find_artifact with: result-encoding: string script: | const artifacts = await github.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, run_id: ${{ github.event.workflow_run.id }}, }); const matchArtifact = artifacts.data.artifacts.filter((artifact) => { return artifact.name == "previewbuild" })[0]; const download = await github.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: matchArtifact.id, archive_format: 'zip', }); return download.url; - name: Create Deployment uses: bobheadxi/deployments@v1 id: deployment with: step: start token: ${{ secrets.GITHUB_TOKEN }} env: Develop ref: ${{ github.head_ref }} - name: Notify the redeploy script uses: distributhor/workflow-webhook@v2 env: webhook_url: ${{ secrets.WEBHOOK_URL }} webhook_secret: ${{ secrets.WEBHOOK_SECRET }} data: '{"url": "${{ steps.find_artifact.outputs.result }}"}' - name: Update deployment status uses: bobheadxi/deployments@v1 if: always() with: step: finish token: ${{ secrets.GITHUB_TOKEN }} status: ${{ job.status }} env: ${{ steps.deployment.outputs.env }} deployment_id: ${{ steps.deployment.outputs.deployment_id }} env_url: https://develop.element.io