|
54 | 54 | targetAccountGroup: "nhs-notify-template-management-dev" |
55 | 55 | targetComponent: ${{ matrix.component }} |
56 | 56 | terraformAction: "apply" |
| 57 | + |
| 58 | + check-event-schemas-version-change: |
| 59 | + name: Chaeck for event schemas package version change |
| 60 | + needs: check-merge-or-workflow-dispatch |
| 61 | + if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true' |
| 62 | + runs-on: ubuntu-latest |
| 63 | + permissions: |
| 64 | + contents: read |
| 65 | + packages: read |
| 66 | + steps: |
| 67 | + - name: Checkout code |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Use Node.js 20 |
| 71 | + uses: actions/setup-node@v4 |
| 72 | + with: |
| 73 | + node-version: '20.18.2' |
| 74 | + registry-url: 'https://npm.pkg.github.com' |
| 75 | + |
| 76 | + - name: check if local version differs from latest published version |
| 77 | + run: | |
| 78 | + published_version=$(npm view @nhsdigital/nhs-notify-templates-test-package --json | jq -r '.["dist-tags"].latest') |
| 79 | + local_version=$(cat packages/event-schemas/package.json | jq -r '.version') |
| 80 | + if [[ $local_version = $published_version ]]; then |
| 81 | + echo "Local version is the same as the latest published version - skipping publish" |
| 82 | + echo "version_changed=false" >> $GITHUB_OUTPUT |
| 83 | + else |
| 84 | + echo "Local version is different to the latest published version - publishing new version" |
| 85 | + echo "version_changed=true" >> $GITHUB_OUTPUT |
| 86 | + fi |
| 87 | +
|
| 88 | + publish-event-schemas: |
| 89 | + name: Publish event schemas package to GitHub package registry |
| 90 | + needs: check-event-schemas-version-change |
| 91 | + if: needs.check-event-schemas-version-change.outputs.version_changed == 'true' |
| 92 | + runs-on: ubuntu-latest |
| 93 | + permissions: |
| 94 | + contents: read |
| 95 | + packages: write |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Checkout code |
| 99 | + uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Use Node.js 20 |
| 102 | + uses: actions/setup-node@v4 |
| 103 | + with: |
| 104 | + node-version: '20.18.2' |
| 105 | + registry-url: 'https://npm.pkg.github.com' |
| 106 | + |
| 107 | + - name: Install dependencies |
| 108 | + run: npm ci |
| 109 | + |
| 110 | + - name: Publish to GitHub Packages |
| 111 | + run: npm publish --workspace packages/event-schemas |
| 112 | + env: |
| 113 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments