Skip to content

Commit

Permalink
feat(create-prs-to-update-vcs-repositories): new github action (#317)
Browse files Browse the repository at this point in the history
* feat(create_prs_for_vcs_repositories_update): add initial files

Signed-off-by: Junya Sasaki <[email protected]>

* renamed from create_prs_for_vcs_repositories_update to create-prs-for-vcs-repositories-update

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-for-vcs-repositories-update): fix a wrong branch name in README.md

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create_prs_for_vcs_repositories_update): add missing shell property

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create_prs_for_vcs_repositories_update): bug fix in missing using property

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create_prs_for_vcs_repositories_update): bug fix for missing back-slash

Signed-off-by: Junya Sasaki <[email protected]>

* doc(create-prs-for-vcs-repositories-update): fix missing description in README.md

Signed-off-by: Junya Sasaki <[email protected]>

* doc(create-prs-for-vcs-repositories-update): fix temporary names

Signed-off-by: Junya Sasaki <[email protected]>

* style(pre-commit): autofix

* fix(create-prs-for-vcs-repositories-update): fix yamllint errors

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-for-vcs-repositories-update): Avoid cspell check fail due to a word "Github"

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-for-vcs-repositories-update): fix wrong comments

  * noqa does not work for cspell check

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-for-vcs-repositories-update): use "-" not "_"

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-for-vcs-repositories-update): renamed as follows except folder

  * create-prs-for-vcs-repositories-update -> create-prs-to-update-vcs-repositories

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-to-update-vcs-repositories): renamed folder as follows

  * create-prs-for-vcs-repositories-update -> create-prs-to-update-vcs-repositories

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-to-update-vcs-repositories): rename a function to be context aware

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-to-update-vcs-repositories): do not declare logger outside of used scope

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-to-update-vcs-repositories): parse args inside of used scope

Signed-off-by: Junya Sasaki <[email protected]>

* fix(create-prs-to-update-vcs-repositories): typos

Signed-off-by: Junya Sasaki <[email protected]>

---------

Signed-off-by: Junya Sasaki <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
sasakisasaki and pre-commit-ci[bot] authored Sep 10, 2024
1 parent de662d6 commit cfeb08b
Show file tree
Hide file tree
Showing 3 changed files with 469 additions and 0 deletions.
60 changes: 60 additions & 0 deletions create-prs-to-update-vcs-repositories/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# create-prs-to-update-vcs-repositories

## Description

This action creates pull requests to update the vcs repositories in the autoware repository.

## Initial setup (within `autowarefoundation` org)

This action uses the <https://github.com/apps/awf-autoware-bot> app to create pull requests.

### Secrets

For this action to use this bot, it requires the following secrets:

- `APP_ID`: The app ID of the bot.
- `PRIVATE_KEY`: The private key of the bot.

These secrets are already set if inside of the autoware repository.

## Usage

```yaml
jobs:
sync-files:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}

- name: Run
uses: autowarefoundation/autoware-github-actions/create-prs-to-update-vcs-repositories@v1
with:
token: ${{ steps.generate-token.outputs.token }}
repo_name: autowarefoundation/autoware
parent_dir: .
base_branch: main
new_branch_prefix: feat/update-
autoware_repos_file_name: autoware.repos
verbosity: 0
```
## Inputs
| Name | Required | Default | Description |
| ------------------------ | -------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| token | true | | The token for pull requests. |
| repo_name | true | | The name of the repository to create pull requests. |
| parent_dir | false | . | The parent directory of the repository. |
| base_branch | false | main | The base branch to create pull requests. |
| new_branch_prefix | false | feat/update- | The prefix of the new branch name. The branch name will be `{new_branch_prefix}-{user_name}/{repository_name}/{new_version}`. |
| autoware_repos_file_name | false | autoware.repos | The name of the vcs imported repository's file (e.g. autoware.repos). |
| verbosity | false | 0 | The verbosity level (0 - 2). |

## Outputs

None.
69 changes: 69 additions & 0 deletions create-prs-to-update-vcs-repositories/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: create-prs-to-update-vcs-repositories
description: Create PRs to update VCS repositories

inputs:
token:
description: GitHub token
required: true
repo_name:
description: Repository name
required: true
parent_dir:
description: Parent directory
required: false
default: ./
base_branch:
description: Base branch
required: false
default: main
new_branch_prefix:
description: New branch prefix. The branch name will be "<new_branch_prefix>-<user_name>/<repository_name>/<new_version>".
required: false
default: feat/update-
autoware_repos_file_name:
description: Autoware repositories file name
required: false
default: autoware.repos
verbosity:
description: Verbosity level
required: false
default: 0

runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64

- name: Install dependencies
shell: bash
run: python -m pip install --upgrade ruamel.yaml PyGithub GitPython packaging

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
token: ${{ inputs.token }}

- name: Fetch all branches
shell: bash
run: git fetch --all

- name: Run Python
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
run: |
VERBOSITY=""
for i in $(seq 1 ${{ inputs.verbosity }}); do
VERBOSITY="$VERBOSITY -v"
done
python ${GITHUB_ACTION_PATH}/create_prs_to_update_vcs_repositories.py \
--repo_name ${{ inputs.repo_name }} \
--parent_dir ${{ inputs.parent_dir }} \
--base_branch ${{ inputs.base_branch }} \
--new_branch_prefix ${{ inputs.new_branch_prefix }} \
--autoware_repos_file_name ${{ inputs.autoware_repos_file_name }} \
$VERBOSITY
Loading

0 comments on commit cfeb08b

Please sign in to comment.