From 2fb4a2a241ca922a123e3a45ca8b17c8b39bd8b0 Mon Sep 17 00:00:00 2001 From: Maksym Shynkarenko <160499295+maksym-shynkarenko@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:39:48 +0300 Subject: [PATCH] ci(.github/action): add deploy-release github action (#157) * ci(.github/action): add deploy-release github action * ci(.github/action): rename the deploy-release action to move-released-issues-and-create-sync-pr. Add a default value of the input pr-team-reviewers * ci(.github/action): change a step to get a previous tag in the move-released-issues-and-create-sync-pr action * ci(.github/action): remove checkout step in the move-released-issues-and-create-sync-pr action * ci(.github/action): change README.md of the move-released-issues-and-create-sync-pr action --- .../README.md | 47 ++++++++++++++++ .../action.yml | 56 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 .github/actions/move-released-issues-and-create-sync-pr-v1/README.md create mode 100644 .github/actions/move-released-issues-and-create-sync-pr-v1/action.yml diff --git a/.github/actions/move-released-issues-and-create-sync-pr-v1/README.md b/.github/actions/move-released-issues-and-create-sync-pr-v1/README.md new file mode 100644 index 00000000..5a9ad602 --- /dev/null +++ b/.github/actions/move-released-issues-and-create-sync-pr-v1/README.md @@ -0,0 +1,47 @@ +# move-released-issues-and-create-sync-pr-v1 + +A GitHub Action to label all related issues with the package version and create a PR to sync branches + +## Inputs + +| Name | Required | Description | Default | +| ------------------- | -------- | -------------------------------------------- | ------------ | +| `token` | Yes | A GitHub token with the required permissions | NA | +| `project-number` | No | A project number of the project board | 66 | +| `head` | No | A head branch to sync from | main | +| `base` | No | A target branch for the created pull request | develop | +| `pr-team-reviewers` | No | Reviewers to tag on the created pull request | axe-api-team | + +## Example usage + +```yaml +name: Deploy release + +jobs: + move-released-issues-and-create-sync-pr: + runs-on: ubuntu-latest + timeout-minutes: 7 + steps: + - uses: actions/checkout@v4 + with: + # Fetch all history + fetch-depth: 0 + - uses: dequelabs/axe-api-team-public/.github/actions/move-released-issues-and-create-sync-pr-v1@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + project-number: '66' + head: main + base: develop + pr-team-reviewers: axe-api-team + env: + # Required for the GH CLI + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +``` + +## Permissions + +This action requires the following permission scopes: + +- `repository-projects: read` - To move issues into a project +- `issues: write` - To add a label into an issue +- `contents: read` - To work with the contents of the repository diff --git a/.github/actions/move-released-issues-and-create-sync-pr-v1/action.yml b/.github/actions/move-released-issues-and-create-sync-pr-v1/action.yml new file mode 100644 index 00000000..00e647de --- /dev/null +++ b/.github/actions/move-released-issues-and-create-sync-pr-v1/action.yml @@ -0,0 +1,56 @@ +name: move-released-issues-and-create-sync-pr-v1 +description: Label all related issues with the package version and create a PR to sync branches + +inputs: + token: + description: 'A GitHub token with the required permissions' + required: true + project-number: + description: 'A project number of the project board' + required: false + default: '66' + head: + description: 'A head branch to sync from' + required: false + default: main + base: + description: 'A target branch for the created pull request' + required: false + default: develop + pr-team-reviewers: + description: 'Reviewers to tag on the created pull request' + required: false + default: axe-api-team + +runs: + using: 'composite' + steps: + - name: Get the previous tag prior to the latest + id: get-previous-tag + shell: bash + run: | + TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1)) + + # Remove "v" prefix + TAG_VERSION=${TAG#v} + + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "tag-version=$TAG_VERSION" >> $GITHUB_OUTPUT + - uses: dequelabs/maksym-testing/.github/actions/generate-commit-list-v1@develop + id: get-commit-list + with: + tag: ${{ steps.get-previous-tag.outputs.tag }} + - uses: dequelabs/axe-api-team-public/.github/actions/label-and-move-released-issues-v1@main + with: + commit-list: ${{ steps.get-commit-list.outputs.commit-list }} + version: ${{ steps.get-previous-tag.outputs.tag-version }} + token: ${{ inputs.token }} + project-number: ${{ inputs.project-number }} + - uses: dequelabs/action-sync-branches@master + with: + github-token: ${{ inputs.token }} + pr-title: 'chore: merge ${{ inputs.head }} into ${{ inputs.base }}' + pr-body: 'Remember to _merge_ (rather than squash) this PR! Also, auto-merge does not work because many of the required checks do not run on the `${{ inputs.head }}` branch.' + pr-team-reviewers: ${{ inputs.pr-team-reviewers }} + head: ${{ inputs.head }} + base: ${{ inputs.base }}