|
| 1 | +name: Publish Alpha |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches-ignore: |
| 6 | + - production |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write |
| 10 | + contents: read |
| 11 | + pull-requests: write |
| 12 | + issues: write |
| 13 | + actions: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + check-affected: |
| 17 | + uses: ./.github/workflows/check-affected.yml |
| 18 | + with: |
| 19 | + target: publish-build |
| 20 | + |
| 21 | + publish: # do we want to add nx-affected to Gamut? |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + needs: check-affected |
| 24 | + if: needs.check-affected.outputs.affected == 'true' |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + ref: ${{ github.event.pull_request.head.ref }} |
| 30 | + |
| 31 | + - name: Set git user |
| 32 | + run: | |
| 33 | + git config --global user.email "[email protected]" |
| 34 | + git config --global user.name "codecademydev" |
| 35 | + git config --global push.default current |
| 36 | +
|
| 37 | + - name: Set npm token |
| 38 | + run: | |
| 39 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc |
| 40 | + env: |
| 41 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 42 | + |
| 43 | + - name: Set Short SHA and PR Number |
| 44 | + id: sha |
| 45 | + run: | |
| 46 | + echo "PR_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV |
| 47 | + echo "PR_NUM=${{ github.event.number }}" >> $GITHUB_ENV |
| 48 | +
|
| 49 | + - uses: ./.github/actions/yarn |
| 50 | + # The context provided here has the current active EKS cluster name (such as `-blue`) appended in the action.yaml |
| 51 | + # - uses: ./.github/actions/k8s-setup |
| 52 | + # with: |
| 53 | + # context: development |
| 54 | + - uses: ./.github/actions/nx-setup |
| 55 | + |
| 56 | + - run: npx nx run-many --target=publish-build --parallel=3 |
| 57 | + |
| 58 | + - name: Check version plan |
| 59 | + run: | |
| 60 | + if ! npx nx release plan:check; then |
| 61 | + echo "Run \`yarn nx release plan\` to generate a version plan." |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Publish alpha packages |
| 66 | + env: |
| 67 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 68 | + run: npx nx run pkg-publish:publish-affected:alpha |
| 69 | + |
| 70 | + - name: List alpha packages versions |
| 71 | + id: published |
| 72 | + continue-on-error: true |
| 73 | + run: | |
| 74 | + shopt -s globstar |
| 75 | + echo 'result<<EOF' >> $GITHUB_OUTPUT |
| 76 | + jq -r 'select(.version | contains("alpha")) | .name + "@" + .version' libs/**/package.json >> $GITHUB_OUTPUT |
| 77 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 78 | +
|
| 79 | + - name: Comment with published alpha packages |
| 80 | + uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2 |
| 81 | + if: steps.published.outputs.result |
| 82 | + with: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + header: Alpha Packages |
| 85 | + recreate: true |
| 86 | + message: | |
| 87 | + ``` |
| 88 | + ${{ steps.published.outputs.result }} |
| 89 | + ``` |
0 commit comments