Error handling with PreloadQuery #1337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Snapshot Release | |
on: | |
workflow_dispatch: | |
issue_comment: | |
types: | |
- created | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
if: | | |
github.repository == 'apollographql/apollo-client-nextjs' && | |
( | |
github.event_name == 'workflow_dispatch' || | |
( | |
github.event.issue.pull_request && | |
( | |
github.event.sender.login == 'benjamn' || | |
github.event.sender.login == 'alessbell' || | |
github.event.sender.login == 'bignimbus' || | |
github.event.sender.login == 'hwillson' || | |
github.event.sender.login == 'jerelmiller' || | |
github.event.sender.login == 'phryneas' | |
) && | |
startsWith(github.event.comment.body, '/release:pr') | |
) | |
) | |
steps: | |
- uses: alessbell/[email protected] | |
if: github.event_name == 'issue_comment' | |
id: comment-branch | |
- name: Get sha | |
if: github.event_name == 'issue_comment' | |
id: parse-sha | |
continue-on-error: true | |
run: | | |
if [ "${{ steps.comment-branch.outputs.head_owner }}" == "apollographql" ]; then | |
echo "sha=${{ steps.comment-branch.outputs.head_sha }}" >> "${GITHUB_OUTPUT}" | |
else | |
sha_from_comment="$(echo $COMMENT_BODY | tr -s ' ' | cut -d ' ' -f2)" | |
if [ $sha_from_comment == "/release:pr" ]; then | |
exit 1 | |
else | |
echo "sha=$sha_from_comment" >> "${GITHUB_OUTPUT}" | |
fi | |
fi | |
env: | |
COMMENT_BODY: ${{ github.event.comment.body }} | |
- name: Comment sha reminder | |
if: steps.parse-sha.outcome == 'failure' | |
uses: peter-evans/[email protected] | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Did you forget to add the sha? Please use `/release:pr <sha>` | |
- name: Fail job | |
if: steps.parse-sha.outcome == 'failure' | |
run: | | |
exit 1 | |
- name: Checkout head ref (comment trigger) | |
if: github.event_name == 'issue_comment' | |
uses: actions/checkout@v4 | |
with: | |
## specify the owner + repository in order to checkout the fork | |
## for community PRs | |
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }} | |
ref: ${{ steps.parse-sha.outputs.sha }} | |
fetch-depth: 0 | |
- name: Checkout head ref (dispatch trigger) | |
if: github.event_name == 'workflow_dispatch' | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.11.0" | |
registry-url: "https://registry.npmjs.org" | |
cache: "yarn" | |
- run: yarn install --immutable | |
# 0.0.0 : to sort lower than any other release | |
# -commit-release : to sort higher than the already released 0.0.0-commit-<hash>, | |
# .0 : format specifier (if the following identifiers will change format, increase this number) | |
# .%ct : commit timestamp (to sort releases by commit date, not by hash) | |
# .%h : commit shorthash | |
- run: echo PKG_VERSION="$(git show --no-patch --format=0.0.0-commit-release.0.%ct.%h)" >> $GITHUB_ENV | |
- name: "@apollo/client-react-streaming: update version" | |
run: | | |
yarn workspace @apollo/client-react-streaming exec npm pkg set "version=${{ env.PKG_VERSION }}" | |
yarn workspace @apollo/client-react-streaming exec jq '{ version: .version, dependencies: .dependencies, peerDependencies: .peerDependencies }' package.json | |
- name: "@apollo/client-react-streaming: publish" | |
run: yarn workspace @apollo/client-react-streaming exec npm publish --access public --tag snapshot --provenance | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: "@apollo/experimental-nextjs-app-support: update version and dependencies" | |
run: | | |
yarn workspace @apollo/experimental-nextjs-app-support exec npm pkg set "dependencies[@apollo/client-react-streaming]=${{ env.PKG_VERSION }}" "version=${{ env.PKG_VERSION }}" | |
yarn workspace @apollo/experimental-nextjs-app-support exec jq '{ version: .version, dependencies: .dependencies, peerDependencies: .peerDependencies }' package.json | |
- name: "@apollo/experimental-nextjs-app-support: publish" | |
run: yarn workspace @apollo/experimental-nextjs-app-support exec npm publish --access public --tag snapshot --provenance | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create comment | |
if: github.event_name == 'issue_comment' | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
A new release has been made for this PR. You can install the package you need using one of | |
* `npm i @apollo/experimental-nextjs-app-support@${{ env.PKG_VERSION }}` | |
* `npm i @apollo/client-react-streaming@${{ env.PKG_VERSION }}` |