chore(deps): update dependency awscli to v1.33.33 #1172
Workflow file for this run
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: create-pr-when-pr-is-merged | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
env: | |
BRANCH_NAME: random-update-in-readme | |
BASE_BRANCH_NAME: main | |
jobs: | |
create-pr-if-outdated: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
ref: ${{ env.BASE_BRANCH_NAME }} | |
- name: update date in readme | |
run: | | |
echo "github PR number: ${{ github.event.pull_request.number }}" | |
sed -i "s/.*Last Merged PR: \(.*\)/- Last Merged PR: #${{ github.event.pull_request.number }}/" README.md | |
- name: leave a comment to the original PR | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `GitHub Actions has been triggered: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}` | |
}) | |
- name: check if need to commit | |
id: need_commit | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "need_commit=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "need_commit=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: commit and push | |
if: steps.need_commit.outputs.need_commit == 'true' | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git checkout -b ${{ env.BRANCH_NAME }} | |
git add . | |
git commit -m 'update date' | |
git push -u origin HEAD -f | |
- name: check if pr exists | |
id: check_pr | |
if: steps.need_commit.outputs.need_commit == 'true' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # used by gh | |
run: | | |
# echo "count=$(gh pr list -S head:${{ env.BRANCH_NAME }} -B ${{ env.BASE_BRANCH_NAME }} | wc -l)" >> "$GITHUB_OUTPUT" | |
pulls=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/nakamasato/github-actions-practice/pulls?head=nakamasato:${{ env.BRANCH_NAME }}&base=${{ env.BASE_BRANCH_NAME }}") | |
echo "$pulls | jq length" | |
count=$(echo "$pulls" | jq length) | |
pr_number=$(echo "$pulls" | jq '.[].number') | |
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" | |
echo "count=$count" >> "$GITHUB_OUTPUT" | |
- name: create pr | |
if: ${{ steps.need_commit.outputs.need_commit == 'true' && steps.check_pr.outputs.count == 0 }} | |
uses: octokit/[email protected] | |
id: create_pr | |
with: | |
route: POST /repos/${{ github.repository }}/pulls | |
title: | # https://github.com/octokit/request-action/issues/118#issuecomment-913823682 | |
|- | |
chore: create pr for random update | |
head: nakamasato:${{ env.BRANCH_NAME }} | |
base: ${{ env.BASE_BRANCH_NAME }} | |
body: | # https://github.com/octokit/request-action#inputs | |
| | |
# What | |
Update readme | |
# Why | |
To check GitHub Actions (triggered by #${{ github.event.pull_request.number }}) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: get pull request number from new pull request | |
if: ${{ steps.need_commit.outputs.need_commit == 'true' && steps.check_pr.outputs.count == 0 }} | |
id: get_pr_number_from_new_pr | |
run: | |
echo "pr_number=${{ fromJson(steps.create_pr.outputs.data).number }}" >> "$GITHUB_OUTPUT" | |
- name: get pull request number | |
id: get_pr_number | |
run: | | |
if [[ ${{ steps.check_pr.outputs.pr_number }} != "" ]];then | |
echo "pr_number=${{ steps.check_pr.outputs.pr_number }}" >> "$GITHUB_OUTPUT" # from existing pr | |
else | |
echo "pr_number=${{ steps.get_pr_number_from_new_pr.outputs.pr_number }}" >> "$GITHUB_OUTPUT" # from new pr | |
fi | |
- name: request reviwer | |
if: steps.get_pr_number.outputs.pr_number != '' | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/${{ github.repository }}/pulls/${{ steps.get_pr_number.outputs.pr_number }}/requested_reviewers | |
reviewers: "[\"${{ github.actor }}\"]" # the person who merges the pr | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: leave a comment to the original PR | |
if: steps.get_pr_number.outputs.pr_number != '' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `## Pull Request\nPlease merge the PR #${{ steps.get_pr_number.outputs.pr_number }}` | |
}) |