Skip to content

[PLAY-1336] Make an action #4

[PLAY-1336] Make an action

[PLAY-1336] Make an action #4

Workflow file for this run

name: Create PR in Nitro
on:
pull_request:
types: [labeled]
jobs:
triggerOnLabel:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'Nitro')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Git
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Generate branch name
id: branch_name
run: |
echo "Original branch: ${GITHUB_REF#refs/heads/}"
NEW_BRANCH="${GITHUB_REF#refs/heads/}_alpha"
echo "::set-output name=branch::${NEW_BRANCH}"
- name: Create new branch in Nitro
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const repo = 'nitro-web';
const owner = 'powerhome';
const branch = ${{ steps.branch_name.outputs.branch }};
const mainSha = await github.rest.repos.getBranch({
owner,
repo,
branch: 'master',
}).then(data => data.data.commit.sha);
await github.rest.git.createRef({
owner,
repo,
ref: `refs/heads/${branch}`,
sha: mainSha
});
- name: Create Pull Request in Nitro
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ steps.branch_name.outputs.branch }}
destination_branch: "master" # Default branch in Nitro
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Automated PR from Repo A"
pr_body: "This is an automated pull request."
destination_repo: "powerhome/nitro-web"