Skip to content

Commit

Permalink
Simplify composer update action to use gh client rather than git
Browse files Browse the repository at this point in the history
  • Loading branch information
caddoo committed Jul 31, 2024
1 parent 5704d70 commit 64e61bb
Showing 1 changed file with 17 additions and 37 deletions.
54 changes: 17 additions & 37 deletions .github/workflows/composer-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,17 @@ jobs:
run: composer install
- name: Prepare branches
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git remote add upstream https://github.com/${GITHUB_REPOSITORY}.git
git push origin --delete composer-update || true
git branch -D composer-update || true
git fetch upstream 5.x-dev
git checkout -f upstream/5.x-dev
git branch composer-update
git checkout -f composer-update
gh auth setup-git
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
gh repo sync
git push origin --delete composer-update || true
git branch -D composer-update || true
git checkout -f 5.x-dev
git branch composer-update
git checkout -f composer-update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update composer dependencies
id: update
run: |
Expand All @@ -75,23 +64,14 @@ jobs:
shell: bash
- name: Push changes
run: |
git commit -m "Update composer dependencies"
git push --set-upstream origin composer-update
gh auth setup-git
git commit -m "Update composer dependencies"
git push --set-upstream origin composer-update
shell: bash
if: steps.update.outputs.message
- name: Create PR
run: |
message=
curl \
--request POST \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title":"[automatic composer updates]",
"body":${{ steps.update.outputs.message }},
"head":"composer-update",
"base":"5.x-dev"
}' \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
shell: bash
gh pr create -B 5.x-dev -H composer-update --title '[automatic composer updates]' --body '${{ steps.update.outputs.message }},'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.update.outputs.message

0 comments on commit 64e61bb

Please sign in to comment.