Publish #1684
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.event.workflow_run.conclusion == 'success' && 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@v6 | |
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 tests' | |
]; | |
const relevantJobs = data.jobs.filter(job => jobsToCheck.includes(job.name)); | |
const failedJobs = relevantJobs.filter(job => job.conclusion === 'failure'); | |
const allSkippedJobs = relevantJobs.every(job => job.conclusion === 'skipped'); | |
if (failedJobs.length > 0) { | |
console.log('🚨 The following tests failed:'); | |
failedJobs.forEach(job => { | |
console.log(`❌ ${job.name}`); | |
}); | |
core.setOutput('jobs_status', 'failure'); | |
} else if (allSkippedJobs) { | |
console.log('⏩ All tests were skipped ⏩'); | |
core.setOutput('jobs_status', 'skipped'); | |
} else { | |
console.log('✅ Required tests passed successfully ✅'); | |
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@v0.37.0' | |
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: tibdex/github-app-token@v2 | |
with: | |
app_id: ${{ secrets.GH_BOT_APP_ID }} | |
private_key: ${{ secrets.GH_BOT_APP_KEY }} | |
- name: Trigger flowforge container build | |
uses: benc-uk/workflow-dispatch@v1 | |
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 }}"}' |