Split back out into two workflows for artifact access
This commit is contained in:
parent
b577d0f2f2
commit
008889d2a8
2 changed files with 65 additions and 65 deletions
65
.github/workflows/build.yaml
vendored
65
.github/workflows/build.yaml
vendored
|
@ -40,68 +40,3 @@ jobs:
|
||||||
name: previewbuild
|
name: previewbuild
|
||||||
path: dist/*.tar.gz
|
path: dist/*.tar.gz
|
||||||
retention-days: ${{ github.ref == 'develop' && 1 || 28 }}
|
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
|
|
||||||
|
|
65
.github/workflows/deploy_develop.yaml
vendored
Normal file
65
.github/workflows/deploy_develop.yaml
vendored
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue