Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(deps): fix git push during yarn.lock deduplication for Dependabot PRs [actions testing PR] #3

Closed
wants to merge 10 commits into from
13 changes: 11 additions & 2 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,16 @@ jobs:
name: UI
needs: [ changed-files ]
if: ${{ needs.changed-files.outputs.ui == 'true' }}
permissions:
contents: write # for pushing deduplicated yarn.lock for dependabot PRs
runs-on: ubuntu-latest
timeout-minutes: 6
env:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 50 # assume PRs are less than 50 commits -- fetch-depth is necessary in order to be able to push
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version: "20" # change in all GH Workflows
Expand All @@ -417,13 +421,18 @@ jobs:
- run: yarn --cwd ui deduplicate
# Deduplicate UI deps for dependabot PRs
- name: Commit deduplicated yarn.lock for Dependabot PRs
if: github.actor == 'dependabot[bot]'
# if: github.actor == 'dependabot[bot]'
run: |
# skip script if there were no changes from deduplicate
if git diff --quiet -- ui/yarn.lock ; then
exit 0
fi

git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add ui/yarn.lock
git commit -s --allow-empty -m 'chore: deduplicate yarn.lock'
git push
git push origin HEAD:$GITHUB_HEAD_REF # we are checked out on a detached HEAD, so need to specify branch
# if lint or deduplicate make changes that are not in the PR, fail the build
- name: Check if lint & deduplicate made changes not present in the PR
run: git diff --exit-code
Expand Down