Skip to content

Levitate / Report breaking changes #25

Levitate / Report breaking changes

Levitate / Report breaking changes #25

name: Levitate / Report breaking changes
on:
workflow_run:
workflows: ["Levitate / Detect breaking changes"]
types: [completed]
jobs:
notify:
name: Report
runs-on: ubuntu-latest
env:
ARTIFACT_NAME: "levitate" # The name of the artifact that we would like to download
ARTIFACT_FOLDER: "${{ github.workspace }}/tmp" # The name of the folder where we will download the artifact to
steps:
- uses: actions/checkout@v3
# Download artifact (as a .zip archive)
- name: "Download artifact"
uses: actions/github-script@v6
env:
RUN_ID: ${{ github.event.workflow_run.id }}
with:
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
const runId = process.env.RUN_ID;
const artifactName = process.env.ARTIFACT_NAME;
const artifactFolder = process.env.ARTIFACT_FOLDER;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runId,
});
const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
if (!artifact) {
throw new Error(`Could not find artifact ${ artifactName } in workflow (${ runId })`);
}
const download = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
fs.mkdirSync(artifactFolder, { recursive: true });
fs.writeFileSync(`${ artifactFolder }/${ artifactName }.zip`, Buffer.from(download.data));
# Unzip artifact
- name: Unzip artifact
run: unzip "${ARTIFACT_FOLDER}/${ARTIFACT_NAME}.zip" -d "${ARTIFACT_FOLDER}"
# Parse the artifact and register fields as step output variables
# (All fields in the JSON will be available as ${{ steps.levitate-run.outputs.<field-name> }}
- name: Parsing levitate result
uses: actions/github-script@v6
id: levitate-run
with:
script: |
const filePath = `${ process.env.ARTIFACT_FOLDER }/result.json`;
const script = require('./.github/workflows/scripts/json-file-to-job-output.js');
await script({ core, filePath });
# Skip all further steps if the "Detect" workflow was skipped
- name: Check if the workflow should be skipped
if: steps.levitate-run.outputs.shouldSkip == 'true'
run: echo "Skipping." && exit 0
shell: bash
# TEST
- name: Parsed as number
if: steps.levitate-run.outputs.testNumber == 123
run: echo "Parsed as number."
# TEST
- name: Parsed as string
if: steps.levitate-run.outputs.testNumber == '123'
run: echo "Parsed as string."
# TEST
- name: Does it actually work?
if: steps.levitate-run.outputs.testNumber == '1234'
run: echo "It's not working at all."
# Continue reporting...
- name: Reporting
if: steps.levitate-run.outputs.shouldSkip != 'true'
run: echo "Reporting the compatibility detection..."
# Comment on Pull Request
- name: Comment on PR
if: steps.levitate-run.outputs.shouldSkip != 'true' && steps.levitate-run.outputs.shouldSkip != 'ANOTHER DUMMY CHECK'
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ steps.levitate-run.outputs.pr_number }}
message: |
⚠️ &nbsp;&nbsp;**Possible breaking changes**
_(Open the links below in a new tab to go to the correct steps)_