Skip to content

Chore(deps-dev): Bump the dev-dependencies group across 1 directory with 13 updates #396

Chore(deps-dev): Bump the dev-dependencies group across 1 directory with 13 updates

Chore(deps-dev): Bump the dev-dependencies group across 1 directory with 13 updates #396

Workflow file for this run

name: fast-forward and release
on:
issue_comment:
types: [created, edited]
jobs:
fast-forward:
# Only run if the comment contains the /fast-forward command.
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/fast-forward') }}
runs-on: ubuntu-latest
# https://docs.github.com/ko/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: write
pull-requests: write
issues: write
outputs:
should_run: ${{ steps.check_branch.outputs.should_run }}
pr_sha: ${{ steps.check_branch.outputs.pr_sha }}
steps:
- name: Check comment
id: check_comment
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
if [[ "$COMMENT_BODY" =~ (^|[[:space:]])/fast-forward($|[[:space:]]) ]]; then
echo "MATCH=true" >> $GITHUB_ENV
else
echo "MATCH=false" >> $GITHUB_ENV
fi
- name: Fast forwarding
if: env.MATCH == 'true'
uses: sequoia-pgp/fast-forward@v1
with:
merge: true
# To reduce the workflow's verbosity, use 'on-error'
# to only post a comment when an error occurs, or 'never' to
# never post a comment. (In all cases the information is
# still available in the step's summary.)
comment: always
- name: Check target branch
if: env.MATCH == 'true'
id: check_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# From https://github.com/sequoia-pgp/fast-forward/blob/main/src/fast-forward.sh
PR_URL="${{ github.event.issue.pull_request.url }}"
if test "x$PR_URL" = x
then
echo "Unable to find pull request's context."
exit 1
fi
GITHUB_PR=$(mktemp)
function get_pr_info {
# https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
curl --silent --show-error --location \
-X GET \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"$PR_URL" >$GITHUB_PR
}
function check_pr_merged {
local merged_status="false"
local attempt=1
local max_attempts=30
local sleep_duration=1
while [ "$merged_status" != "true" ] && [ $attempt -le $max_attempts ]; do
get_pr_info
merged_status=$(jq -r ".merged" <$GITHUB_PR)
if [ "$merged_status" = "true" ]; then
break
else
sleep $sleep_duration
((attempt++))
fi
done
if [ $attempt -gt $max_attempts ]; then
echo "The maximum number of attempts has been reached. The pull request was not merged."
exit 1
fi
}
get_pr_info
BASE_REF=$(jq -r ".base.ref" <$GITHUB_PR)
if [ "$BASE_REF" = "main" ]; then
echo "should_run=true" >> $GITHUB_OUTPUT
check_pr_merged
HEAD_SHA=$(jq -r ".head.sha" <$GITHUB_PR)
echo "pr_sha=$HEAD_SHA" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
release:
name: Release
needs: fast-forward
if: needs.fast-forward.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Setup
uses: ./.github/actions/node-setup
- name: Is versioning PR
run: |
cd ./.changeset || exit
md_files=$(find . -maxdepth 1 -type f -name "*.md" ! -name "README.md")
if [ -n "$md_files" ]; then
git branch changeset-release/main $PR_SHA
fi
env:
PR_SHA: ${{ needs.fast-forward.outputs.pr_sha }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
commit: "Chore: Version Packages"
publish: yarn run publish
version: git reset --hard changeset-release/main && yarn run changeset:version
setupGitUser: true
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Show log on failure
if: failure()
run: |
cd /home/runner/.npm/_logs/ || exit
for file in *; do
echo "=== File: $file ==="
cat "$file"
echo -e "\n\n"
done