Skip to content

Commit

Permalink
Merge pull request #9 from cern-vc/develop
Browse files Browse the repository at this point in the history
👷 Update CI
  • Loading branch information
SamuelGuillemet authored Aug 17, 2023
2 parents ed50aa5 + 95cd84f commit c7ada42
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,45 @@ on:
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

jobs:
get-version:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get-tag-name.outputs.tag_name }}
steps:
- name: Download artifact
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 == "version_number"
})[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}/version_number.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip version_number.zip

- name: Get tag name
id: get-tag-name
run: |
echo "tag_name=$(cat version_number)" >> $GITHUB_OUTPUT
publish-npm:
runs-on: ubuntu-latest
# Disable this job if the version output of the workflow_run workflow is empty
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: get-version
if: needs.get-version.outputs.tag_name != ''
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/release-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ jobs:
tag_name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}

fail-on-empty-release:
store-version:
needs: release-on-push
runs-on: ubuntu-latest
if: ${{ needs.release-on-push.outputs.version == '' }}
steps:
- name: Fail on empty release
run: exit 1
- name: Save version
run: |
mkdir -p ./version
echo "${{ needs.release-on-push.outputs.version }}" > ./version/version_number
- uses: actions/upload-artifact@v3
with:
name: version_number
path: ./version

0 comments on commit c7ada42

Please sign in to comment.