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