102 lines
3.1 KiB
YAML
102 lines
3.1 KiB
YAML
name: Build
|
|
on:
|
|
pull_request: { }
|
|
push:
|
|
branches: [ master, develop ]
|
|
repository_dispatch:
|
|
types: [ element-web-notify ]
|
|
jobs:
|
|
build:
|
|
name: "Build"
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
# This must be set for fetchdep.sh to get the right branch
|
|
PR_NUMBER: ${{github.event.number}}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
cache: 'yarn'
|
|
|
|
- name: Install SDKs
|
|
run: "./scripts/fetch-develop.deps.sh --depth 1"
|
|
|
|
- name: Install Dependencies
|
|
run: "yarn install"
|
|
|
|
- name: Build & Package
|
|
run: "./scripts/ci_package.sh"
|
|
|
|
- name: Upload webpack-stats.json
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
path: webpack-stats.json
|
|
retention-days: 28
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
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: Create Deployment ID
|
|
uses: altinukshini/deployment-action@v1.2.6
|
|
id: deployment
|
|
with:
|
|
token: "${{ github.token }}"
|
|
environment_url: https://develop.element.io
|
|
environment: Develop
|
|
initial_status: in_progress
|
|
pr: true
|
|
pr_id: ${{ github.event.pull_request.number }}
|
|
ref: ${{ github.head_ref }}
|
|
|
|
- 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;
|
|
|
|
# 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: altinukshini/deployment-status@v1.0.1
|
|
with:
|
|
token: "${{ github.token }}"
|
|
environment_url: https://develop.element.io
|
|
state: "success"
|
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
|
pr: true
|
|
pr_id: ${{ github.event.pull_request.number }}
|
|
- name: Update deployment status (failure)
|
|
if: failure()
|
|
uses: altinukshini/deployment-status@v1.0.1
|
|
with:
|
|
token: "${{ github.token }}"
|
|
state: "failure"
|
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|