mirror of
https://github.com/bitwarden/browser.git
synced 2024-08-31 00:01:03 +02:00
Improve bump-jslib GH action (#1030)
* Change reviewer to dept-engineering * Use modern command substitution instead of backticks * Fix truncation of git log, improve Github syntax * Change PR title
This commit is contained in:
parent
14e9784297
commit
f2c9c9ebbb
25
.github/workflows/bump-jslib.yml
vendored
25
.github/workflows/bump-jslib.yml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
|||
if [ "$CHECKED_OUT_BRANCH_NAME" = "master" ]; then
|
||||
TARGET_BRANCH_NAME="auto-bump-jslib"
|
||||
git fetch origin
|
||||
EXISTING_PR=`git ls-remote --heads origin $TARGET_BRANCH_NAME | wc -l`
|
||||
EXISTING_PR=$(git ls-remote --heads origin $TARGET_BRANCH_NAME | wc -l)
|
||||
if [ "$EXISTING_PR" -gt 0 ]; then
|
||||
git checkout $TARGET_BRANCH_NAME
|
||||
echo "[*] Checked out existing PR branch $TARGET_BRANCH_NAME"
|
||||
|
@ -39,11 +39,11 @@ jobs:
|
|||
fi
|
||||
|
||||
npm run sub:init
|
||||
OLD_JSLIB_HASH=`git submodule status | awk '{print $1}'`
|
||||
OLD_JSLIB_HASH=$(git submodule status | awk '{print $1}')
|
||||
|
||||
npm run sub:update
|
||||
|
||||
if [ `git diff jslib | wc -l` -eq 0 ]; then
|
||||
if [ $(git diff jslib | wc -l) -eq 0 ]; then
|
||||
echo "Unable to bump jslib: branch $TARGET_BRANCH_NAME is already using the latest jslib commit."
|
||||
if [ "$EXISTING_PR" -gt 0 ]; then
|
||||
echo "Try merging the $TARGET_BRANCH_NAME branch into master first."
|
||||
|
@ -54,38 +54,37 @@ jobs:
|
|||
git add jslib
|
||||
git commit -m "Bump jslib"
|
||||
|
||||
NEW_JSLIB_HASH=`git submodule status | awk '{print $1}'`
|
||||
echo "[*] Bumped jslib to $NEW_JSLIB_HASH"
|
||||
|
||||
if [ "$EXISTING_PR" -eq 0 ]; then
|
||||
git push -u origin $TARGET_BRANCH_NAME
|
||||
else
|
||||
git push origin $TARGET_BRANCH_NAME
|
||||
fi
|
||||
echo "[*] Pushed to $TARGET_BRANCH_NAME"
|
||||
|
||||
cd jslib
|
||||
GIT_LOG=`git log $OLD_JSLIB_HASH..$NEW_JSLIB_HASH --oneline | sed 's/^/* /g' | sed 's/#[0-9]*[)]/bitwarden\/jslib&/g'`
|
||||
|
||||
echo "::set-output name=git-log::${GIT_LOG}"
|
||||
echo "::set-output name=old-jslib-hash::${OLD_JSLIB_HASH}"
|
||||
echo "::set-output name=existing-pr::${EXISTING_PR}"
|
||||
|
||||
- name: Submit or update PR against master branch
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
NEW_JSLIB_HASH=$(git submodule status | awk '{print $1}')
|
||||
cd jslib
|
||||
GIT_LOG="$(git log $OLD_JSLIB_HASH..$NEW_JSLIB_HASH --oneline | sed 's/^[a-zA-Z0-9]*/* `&`/g' | sed 's/#[0-9]*[)]/bitwarden\/jslib&/g')"
|
||||
cd ..
|
||||
|
||||
BODY_TEXT="@${{github.actor}} would like to bump jslib in this repo. This will pull in the following new commits:
|
||||
$GIT_LOG"
|
||||
|
||||
if [ "$EXISTING_PR" -eq 0 ]; then
|
||||
gh pr create --title "Auto bump jslib" \
|
||||
gh pr create --title "[Bot] Bump jslib" \
|
||||
--body "$BODY_TEXT" \
|
||||
--reviewer eliykat
|
||||
--reviewer bitwarden/dept-engineering
|
||||
echo "[*] Submitted PR against master branch"
|
||||
else
|
||||
gh pr comment --body "$BODY_TEXT"
|
||||
echo "[*] Updated existing PR"
|
||||
fi
|
||||
env:
|
||||
GIT_LOG: ${{ steps.bump.outputs.git-log }}
|
||||
OLD_JSLIB_HASH: ${{ steps.bump.outputs.old-jslib-hash }}
|
||||
EXISTING_PR: ${{ steps.bump.outputs.existing-pr }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user