|
62 | 62 | --targetAccountGroup "nhs-notify-supplier-api-dev" \ |
63 | 63 | --targetComponent "${{ matrix.component }}" \ |
64 | 64 | --terraformAction "apply" |
| 65 | +
|
| 66 | + check-event-schemas-version-change: |
| 67 | + name: Check for event schemas package version change |
| 68 | + needs: check-merge-or-workflow-dispatch |
| 69 | + if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true' |
| 70 | + outputs: |
| 71 | + version_changed: ${{ steps.check-version.outputs.version_changed }} |
| 72 | + runs-on: ubuntu-latest |
| 73 | + permissions: |
| 74 | + contents: read |
| 75 | + packages: read |
| 76 | + steps: |
| 77 | + - name: Checkout code |
| 78 | + |
| 79 | + |
| 80 | + - name: Setup NodeJS |
| 81 | + uses: actions/setup-node@v4 |
| 82 | + with: |
| 83 | + node-version: ${{ inputs.nodejs_version }} |
| 84 | + |
| 85 | + - name: check if local version differs from latest published version |
| 86 | + id: check-version |
| 87 | + run: | |
| 88 | + published_version=$(npm view @nhsdigital/nhs-notify-event-schemas-supplier-api --json 2>/dev/null | jq -r '.["dist-tags"].latest // "null"') |
| 89 | + echo "Published version: $published_version" |
| 90 | +
|
| 91 | + local_version=$(jq -r '.version' internal/events/package.json) |
| 92 | + echo "Local version: $local_version" |
| 93 | +
|
| 94 | + if [[ $local_version = $published_version ]]; then |
| 95 | + echo "Local version is the same as the latest published version - skipping publish" |
| 96 | + echo "version_changed=false" >> $GITHUB_OUTPUT |
| 97 | + else |
| 98 | + echo "Local version is different to the latest published version - publishing new version" |
| 99 | + echo "version_changed=true" >> $GITHUB_OUTPUT |
| 100 | + fi |
| 101 | +
|
| 102 | + test-contract: |
| 103 | + name: "Test contracts (provider)" |
| 104 | + needs: check-event-schemas-version-change |
| 105 | + if: needs.check-event-schemas-version-change.outputs.version_changed == 'true' |
| 106 | + runs-on: ubuntu-latest |
| 107 | + permissions: |
| 108 | + contents: read |
| 109 | + packages: read |
| 110 | + steps: |
| 111 | + - name: "Checkout code" |
| 112 | + |
| 113 | + - name: Setup NodeJS |
| 114 | + uses: actions/setup-node@v4 |
| 115 | + with: |
| 116 | + node-version: ${{ inputs.nodejs_version }} |
| 117 | + - name: "Install dependencies" |
| 118 | + run: npm ci |
| 119 | + - name: "Run provider contract tests" |
| 120 | + run: make test-contract |
| 121 | + env: |
| 122 | + GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 123 | + |
| 124 | + publish-event-schemas: |
| 125 | + name: Publish event schemas package to GitHub package registry |
| 126 | + needs: |
| 127 | + - check-event-schemas-version-change |
| 128 | + - test-contract |
| 129 | + if: needs.check-event-schemas-version-change.outputs.version_changed == 'true' |
| 130 | + runs-on: ubuntu-latest |
| 131 | + permissions: |
| 132 | + contents: read |
| 133 | + packages: write |
| 134 | + |
| 135 | + steps: |
| 136 | + - name: Checkout code |
| 137 | + |
| 138 | + |
| 139 | + - name: Setup NodeJS |
| 140 | + uses: actions/setup-node@v4 |
| 141 | + with: |
| 142 | + node-version: ${{ inputs.nodejs_version }} |
| 143 | + registry-url: 'https://npm.pkg.github.com' |
| 144 | + |
| 145 | + - name: Install dependencies |
| 146 | + run: npm ci |
| 147 | + |
| 148 | + - name: Publish to GitHub Packages |
| 149 | + run: npm publish --workspace internal/events |
| 150 | + env: |
| 151 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments