Skip to content

Publish

Publish #4254

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
localfs_release_name:
description: 'localfs package version'
required: false
default: 'nightly'
localfs_ref:
description: 'localfs package ref'
required: false
workflow_run:
workflows:
- 'Tests'
branches:
- main
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-tests-status:
name: Check tests statuses
if: |
github.ref == 'refs/heads/main' ||
( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' )
runs-on: ubuntu-latest
outputs:
tests_status: ${{ steps.check-tests-jobs-status.outputs.jobs_status }}
steps:
- name: Check statuses
id: check-tests-jobs-status
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (context.eventName === 'workflow_dispatch') {
console.log('✅ Workflow manually dispatched. Skipping tests jobs check. ✅');
core.setOutput('jobs_status', 'success');
return;
}
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const jobsToCheck = [
'Backend tests',
'Postgres tests',
'UI unit tests',
'UI EE tests',
'UI OS tests'
];
const relevantJobs = data.jobs.filter(job =>
jobsToCheck.some(jobName => job.name.startsWith(jobName))
);
const failedJobs = relevantJobs.filter(job => job.conclusion === 'failure');
const allSkippedJobs = relevantJobs.every(job => job.conclusion === 'skipped');
console.log('Relevant jobs found:', JSON.stringify(relevantJobs, null, 2));
if (failedJobs.length > 0) {
console.log('🚨 The following tests failed:');
await core.summary
.addHeading('Failed Tests 🚨');
let failedList = '';
failedJobs.forEach(job => {
console.log(`❌ ${job.name}`);
failedList += `- ❌ ${job.name}\n`;
});
await core.summary
.addRaw(failedList)
.write();
core.setOutput('jobs_status', 'failure');
} else if (allSkippedJobs) {
console.log('⏩ All tests were skipped ⏩');
await core.summary
.addHeading('Test Status ⏩')
.addRaw('All tests were skipped')
.write();
core.setOutput('jobs_status', 'skipped');
} else {
console.log('✅ Required tests passed successfully ✅');
await core.summary
.addHeading('Test Status ✅')
.addRaw('All required tests passed successfully')
.write();
core.setOutput('jobs_status', 'success');
}
publish:
if: |
needs.check-tests-status.outputs.tests_status == 'success' && github.ref == 'refs/heads/main'
needs: check-tests-status
uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@publish_node_package/v1'
with:
package_name: flowfuse
build_package: true
publish_package: true
package_dependencies: |
@flowfuse/driver-localfs=nightly
secrets:
npm_registry_token: ${{ secrets.NPM_PUBLISH_TOKEN }}
sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }}
sentry_organisation: ${{ secrets.SENTRY_ORGANISATION }}
sentry_project: ${{ secrets.SENTRY_PROJECT }}
dispatch_container_build:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.GH_BOT_APP_ID }}
private-key: ${{ secrets.GH_BOT_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: helm
- name: Trigger flowforge container build
uses: benc-uk/workflow-dispatch@31e2b3319479a63f0ab15bf800eff9e913504e26 # v1.3.2
with:
workflow: flowforge-container.yml
repo: flowfuse/helm
ref: main
token: ${{ steps.generate_token.outputs.token }}
inputs: '{"flowforge_ref": "${{ github.ref }}", "flowforge_release_name": "${{ env.release_name }}"}'
notify-slack:
name: Notify on failure
if: failure()
needs: [check-tests-status, publish]
runs-on: ubuntu-latest
steps:
- name: Send notification
uses: FlowFuse/github-actions-workflows/actions/slack_notification@slack_notification/v1
with:
bot-token: ${{ secrets.SLACK_GHBOT_TOKEN }}
mode: channel
blocks: |
[
{ "type": "header", "text": { "type": "plain_text", "text": ":x: FlowFuse npm package publish pipeline failed", "emoji": true } },
{ "type": "divider" },
{ "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [
{ "type": "emoji", "name": "warning" },
{ "type": "text", "text": " Deployment to FFC environments will not happen until this issue is resolved.", "style": { "bold": true } }
] } ] },
{ "type": "divider" },
{ "type": "actions", "elements": [
{ "type": "button", "text": { "type": "plain_text", "text": "View Failed Workflow", "emoji": true }, "style": "primary", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "value": "view_workflow" }
] }
]