2022-05-11 02:11:45 +08:00
|
|
|
name: Netlify Main
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["Build"]
|
|
|
|
types:
|
|
|
|
- completed
|
2022-12-21 20:36:00 +08:00
|
|
|
branches:
|
2022-12-21 21:09:41 +08:00
|
|
|
- "main"
|
2022-05-11 02:11:45 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
2022-05-11 02:35:40 +08:00
|
|
|
permissions:
|
|
|
|
deployments: write
|
2022-12-23 04:22:54 +08:00
|
|
|
# Important: the 'branches' filter above will match the 'main' branch on forks,
|
|
|
|
# so we need to check the head repo too in order to not run on PRs from forks
|
|
|
|
# We check the branch name again too just for completeness
|
|
|
|
# (Is there a nicer way to see if a PR is from a fork?)
|
|
|
|
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_repository.full_name == 'vector-im/element-call' && github.event.workflow_run.head_branch == 'main'
|
2022-05-11 02:11:45 +08:00
|
|
|
steps:
|
2022-05-11 03:48:30 +08:00
|
|
|
- name: Create Deployment
|
|
|
|
uses: bobheadxi/deployments@v1
|
|
|
|
id: deployment
|
|
|
|
with:
|
|
|
|
step: start
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
env: main-branch-cd
|
|
|
|
ref: ${{ github.event.workflow_run.head_sha }}
|
|
|
|
|
2022-12-10 03:34:25 +08:00
|
|
|
- name: "Download artifact"
|
2022-05-11 02:11:45 +08:00
|
|
|
uses: actions/github-script@v3.1.0
|
|
|
|
with:
|
|
|
|
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 == "build"
|
|
|
|
})[0];
|
|
|
|
const download = await github.actions.downloadArtifact({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
artifact_id: matchArtifact.id,
|
|
|
|
archive_format: 'zip',
|
|
|
|
});
|
|
|
|
const fs = require('fs');
|
|
|
|
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
|
|
|
|
|
|
|
|
- name: Extract Artifacts
|
2022-05-11 02:39:27 +08:00
|
|
|
run: unzip -d dist build.zip && rm build.zip
|
2022-05-11 02:11:45 +08:00
|
|
|
|
2022-05-11 20:20:35 +08:00
|
|
|
- name: Add redirects file
|
|
|
|
# We fetch from github directly as we don't bother checking out the repo
|
|
|
|
run: curl -s https://raw.githubusercontent.com/vector-im/element-call/main/config/netlify_redirects > dist/_redirects
|
2022-05-11 18:39:48 +08:00
|
|
|
|
2022-11-04 03:01:13 +08:00
|
|
|
- name: Add config file
|
|
|
|
run: curl -s https://raw.githubusercontent.com/vector-im/element-call/main/config/element_io_develop.json > dist/config.json
|
|
|
|
|
2022-05-11 02:11:45 +08:00
|
|
|
- name: Deploy to Netlify
|
|
|
|
id: netlify
|
2022-05-11 02:55:05 +08:00
|
|
|
uses: nwtgck/actions-netlify@v1.2.3
|
2022-05-11 02:11:45 +08:00
|
|
|
with:
|
|
|
|
publish-dir: dist
|
|
|
|
deploy-message: "Deploy from GitHub Actions"
|
2022-05-11 02:55:05 +08:00
|
|
|
production-branch: main
|
|
|
|
production-deploy: true
|
2022-05-11 02:11:45 +08:00
|
|
|
# These don't work because we're in workflow_run
|
|
|
|
enable-pull-request-comment: false
|
|
|
|
enable-commit-comment: false
|
2022-05-11 02:55:05 +08:00
|
|
|
github-deployment-environment: main
|
2022-05-11 02:11:45 +08:00
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
|
|
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
|
|
|
timeout-minutes: 1
|
2022-05-11 03:48:30 +08:00
|
|
|
|
|
|
|
- name: Update deployment status
|
|
|
|
uses: bobheadxi/deployments@v1
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
step: finish
|
|
|
|
override: false
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env: ${{ steps.deployment.outputs.env }}
|
|
|
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
|
|
|
env_url: ${{ steps.netlify.outputs.deploy-url }}
|