diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f7c6a72051..2e0a1ada44 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,68 +40,3 @@ jobs: name: previewbuild path: dist/*.tar.gz retention-days: ${{ github.ref == 'develop' && 1 || 28 }} - - deploy: - name: "Deploy to develop.element.io" - needs: build - runs-on: ubuntu-latest - # if: github.event_name == 'push' && github.ref == 'develop' - steps: - - name: Find Artifact ID - uses: actions/github-script@v3.1.0 - id: find_artifact - with: - result-encoding: string - script: | - var artifacts = await github.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{github.run_id }}, - }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "previewbuild" - })[0]; - return matchArtifact.id; - - - name: Create Deployment - uses: avakar/create-deployment@v1 - id: deployment - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - environment: Develop - initial_status: in_progress - ref: ${{ github.head_ref }} - transient_environment: true - auto_merge: false - task: deploy - payload: '{"artifact_id": "${{ steps.find_artifact.outputs.result }}"}' - - # TODO -# - name: Invoke deployment hook -# uses: distributhor/workflow-webhook@v2 -# env: -# webhook_url: https://test.tun.bit.ovh -# webhook_secret: FooBar -# data: '{ "artifact_id": "${{steps.find_artifact.outputs.result}}" }' - - - name: Update deployment status (success) - if: success() - uses: avakar/set-deployment-status@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - environment: Develop - environment_url: https://develop.element.io - state: "success" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} - auto_inactive: true - - name: Update deployment status (failure) - if: failure() - uses: avakar/set-deployment-status@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - state: "failure" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} - environment: Develop diff --git a/.github/workflows/deploy_develop.yaml b/.github/workflows/deploy_develop.yaml new file mode 100644 index 0000000000..90b8ace59e --- /dev/null +++ b/.github/workflows/deploy_develop.yaml @@ -0,0 +1,65 @@ +# Triggers after the Build has finished, +# because artifacts are not externally available +# until the end of their workflow. +name: Build +on: + workflow_run: + workflows: [ "Build" ] + types: + - completed +jobs: + deploy: + needs: build + runs-on: ubuntu-latest + 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: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.run_id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "previewbuild" + })[0]; + return matchArtifact.id; + + - name: Create Deployment + uses: avakar/create-deployment@v1.0.2 + id: deployment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + environment: Develop + initial_status: in_progress + ref: ${{ github.head_ref }} + transient_environment: false + auto_merge: false + task: deploy + payload: '{"artifact_id": "${{ steps.find_artifact.outputs.result }}"}' + + - name: Update deployment status (success) + if: success() + uses: avakar/set-deployment-status@v1.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + environment: Develop + environment_url: https://develop.element.io + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + auto_inactive: true + - name: Update deployment status (failure) + if: failure() + uses: avakar/set-deployment-status@v1.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + environment: Develop