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

build: update Github Action to use fork from yoshi-code-bot #2162

Merged
merged 34 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3ffb496
testing
parthea Jun 20, 2023
bcffc57
testing
parthea Jun 20, 2023
1c486fa
testing
parthea Jun 20, 2023
4b1fc65
testing
parthea Jun 20, 2023
a136f34
testing
parthea Jun 20, 2023
9e6cc40
testing
parthea Jun 20, 2023
dc4fce5
testing
parthea Jun 20, 2023
19b9632
testing
parthea Jun 20, 2023
99a88e3
Merge branch 'main' into testing
parthea Jun 27, 2023
0e0a9ac
Merge branch 'main' into testing
parthea Jul 5, 2023
3263da7
Merge branch 'main' into testing
parthea Jul 11, 2023
4ca6dd3
Merge branch 'main' into testing
parthea Jul 18, 2023
4795303
Merge branch 'main' into testing
parthea Jul 25, 2023
9837f45
Merge branch 'main' into testing
parthea Aug 1, 2023
539ff66
Merge branch 'main' into testing
parthea Aug 4, 2023
9956b06
Merge branch 'main' into testing
parthea Aug 15, 2023
e48d018
Merge branch 'main' into testing
parthea Aug 24, 2023
e33996b
Merge branch 'main' into testing
parthea Sep 6, 2023
2499eef
Merge branch 'main' into testing
parthea Sep 12, 2023
ffb6705
Merge branch 'main' into testing
parthea Sep 18, 2023
cb13b9d
Merge branch 'main' into testing
parthea Sep 25, 2023
8991a9d
Merge branch 'main' into testing
parthea Oct 3, 2023
dbd7697
Merge branch 'main' into testing
parthea Oct 10, 2023
59cfa5a
Merge branch 'main' into testing
parthea Oct 17, 2023
24bfa48
Merge branch 'main' into testing
parthea Oct 24, 2023
c79d339
Merge branch 'main' into testing
parthea Oct 31, 2023
6662895
Merge branch 'main' into testing
parthea Nov 7, 2023
ed86f0a
Merge branch 'main' into testing
parthea Nov 14, 2023
5ccd822
Merge branch 'main' into testing
parthea Nov 29, 2023
c604a4a
Merge branch 'main' into testing
parthea Dec 7, 2023
cefd94b
Merge branch 'main' into testing
parthea Dec 12, 2023
2e6e1bc
Merge branch 'main' into testing
parthea Jan 4, 2024
0f57a6f
Merge branch 'main' into testing
parthea Jan 8, 2024
8d652c3
trigger on cron job
parthea Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 16 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ jobs:
steps:
- name: Get current date
id: date
run: echo "::set-output name=current_date::$(date +'%Y-%m-%d')"
run: echo "::set-output name=current_date::$(date +'%Y-%m-%d-%HH%MM%SS')"

- name: Sync fork
run: gh repo sync $REPOSITORY -b $BRANCH_NAME
env:
REPOSITORY: 'yoshi-code-bot/google-api-python-client'
BRANCH_NAME: 'refs/heads/main'
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}

- name: Check out main branch
uses: actions/checkout@v4
with:
ref: refs/heads/main
repository: 'yoshi-code-bot/google-api-python-client'
token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}

- name: Create branch
run: |
Expand Down Expand Up @@ -68,7 +77,7 @@ jobs:
working-directory: ./scripts

- name: Push changes
run: git push -f --set-upstream origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
run: git push -u origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}

- name: Prepare summary for PR Body
id: pr_body
Expand All @@ -83,43 +92,8 @@ jobs:
working-directory: ./scripts

- name: Create PR
uses: actions/github-script@v7.0.1
with:
github-token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
script: |
async function createPR () {
const { owner, repo } = context.repo
const branch = 'update-discovery-artifacts-${{ steps.date.outputs.current_date }}'
let prBody = `${{ steps.pr_body.outputs.change_summary }}`
const prTitle = 'chore: Update discovery artifacts'
const pullRequests = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: `${owner}:${branch}`,
state: 'open'
})

if (pullRequests.data.length === 1) {
prNumber = pullRequests.data[0].number
await github.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: prNumber,
title: prTitle,
body: prBody
})
console.log('Updated PR')
} else {
const createPrResult = await github.rest.pulls.create({
owner: owner,
repo: repo,
base: 'main',
head: `${owner}:${branch}`,
title: prTitle,
body: prBody
})
prNumber = createPrResult.data.number
console.log('Created PR')
}
}
createPR()
env:
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
PR_TITLE: "chore: Update discovery artifacts"
run: |
gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${{ steps.pr_body.outputs.change_summary }}"