Skip to content

TeamsFx-CD Triggers #1104

TeamsFx-CD Triggers

TeamsFx-CD Triggers #1104

Workflow file for this run

name: TeamsFx-CD Triggers
on:
workflow_run:
workflows: ["CD"]
branches: ["main", "dev", "hotfix/**"]
types: ["completed"]
jobs:
TeamsFxCICDTestMainTriggers:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
steps:
- name: Trigger TeamsFx-CICD-Test
run: |
curl \
-u :${{ secrets.GHEC_BOT_PAT }} \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/devdiv-azure-service-dmitryr/TeamsFx-CICD-Test/actions/workflows/trigger_cicd_by_main.yml/dispatches \
-d "{\"ref\":\"main\"}"
TeamsFxCICDTestDevTriggers:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'dev' }}
steps:
- name: Trigger TeamsFx-CICD-Test
run: |
curl \
-u :${{ secrets.GHEC_BOT_PAT }} \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/devdiv-azure-service-dmitryr/TeamsFx-CICD-Test/actions/workflows/trigger_cicd_by_dev.yml/dispatches \
-d "{\"ref\":\"main\"}"
DownloadAndOutput:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
zipLink: ${{ steps.downloadUrl.outputs.result }}
pre_id: ${{ steps.preid.outputs.result }}
server_version: ${{ steps.version.outputs.result }}
stage: ${{ steps.series.outputs.result }}
steps:
- name: Download artifact
id: downloadUrl
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "release"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/release.zip`, Buffer.from(download.data));
return matchArtifact.url
- name: Unzip artifact
run: unzip release.zip
- name: Get teamsfx-server version
id: version
uses: actions/github-script@v6
with:
script: |
let rawData = require('fs').readFileSync('./versions.json', {encoding:'utf8', flag:'r'});
let pkgs = JSON.parse(rawData);
let server = pkgs.find(item => item.name === "@microsoft/teamsfx-server")
console.log("==================", server.version)
return server.version
- name: Get stage input
id: series
uses: actions/github-script@v6
with:
script: |
let rawData = require('fs').readFileSync('./series.txt', {encoding:'utf8', flag:'r'});
if (rawData.trim() === "") rawData = "undefined"
console.log('-----------------', rawData)
return rawData;
- run: npm install semver
- name: Get teamsfx-server preid
id: preid
uses: actions/github-script@v6
with:
script: |
let rawData = require('fs').readFileSync('./versions.json', {encoding:'utf8', flag:'r'});
let pkgs = JSON.parse(rawData);
let server = pkgs.find(item => item.name === "@microsoft/teamsfx-server")
let semver = require('semver')
if(semver.prerelease(server.version)) {
console.log("===========", semver.prerelease(server.version)[0])
return semver.prerelease(server.version)[0]
} else {
console.log("=========== stable")
return "stable"
}
CheckSetupSuccess:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
token: ${{ secrets.CD_PAT }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Setup project
id: setup
run: npm run setup
continue-on-error: true
- name: Info
if: steps.setup.outcome != 'success'
run: |
echo "`npm run setup` failed after current project finish CD,\
it may be the inconsistency of package dependencies caused by separate release,\
please confirm this problem will not affect the CI of subsequent PRs."