Ability to change important network properties #539
This file contains hidden or 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 version branch & PR <working>/* -> version | |
| on: | |
| push: | |
| branches: [feature/*, bugfix/*] | |
| jobs: | |
| auto-pr: | |
| name: Automated Master Branch PR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| pull-requests: write | |
| steps: | |
| # Work around https://github.com/actions/checkout/issues/760 | |
| - name: Add safe.directory | |
| run: | | |
| git config --global --add safe.directory /github/workspace | |
| git config --global --add safe.directory $PWD | |
| - name: Checkout repository | |
| # ref.: actions/checkout v4.2.2 | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: Extract branch name on pull request | |
| shell: bash | |
| run: | | |
| set -x | |
| git branch -r -l | |
| echo "(current dir): $PWD" && ls -l ./ | |
| chmod -Rv 555 ./scripts | |
| RELEASE_VER=$(./scripts/version.sh) && echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV | |
| RELEASE_BRANCH="release/$RELEASE_VER" && echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV | |
| REPOSITORY_NAME="${{ github.event.repository.name }}" && echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV | |
| echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV | |
| echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV | |
| echo "MASTER_REF=$(git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | head -1 | sed 's/HEAD//')" >> $GITHUB_ENV | |
| git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | egrep -q "refs/tags/${RELEASE_VER}$" && echo "RELEASE_EXISTS=true" >> $GITHUB_ENV || echo "RELEASE_EXISTS=false" >> $GITHUB_ENV | |
| ( git show-branch "origin/$RELEASE_BRANCH" || git show-branch "remotes/origin/$RELEASE_BRANCH" ) && echo "TARGET_BRANCH_EXISTS=true" >> $GITHUB_ENV || echo "TARGET_BRANCH_EXISTS=false" >> $GITHUB_ENV | |
| - name: Print debug data before publishing | |
| run: | | |
| echo "Repository name: ${{ env.REPOSITORY_NAME }}" | |
| echo " Source branch: ${{ env.SOURCE_BRANCH }}" | |
| echo " Default branch: ${{ env.DEFAULT_BRANCH }}" | |
| echo " Master refer.: ${{ env.MASTER_REF }}" | |
| echo "Release version: ${{ env.RELEASE_VER }}" | |
| echo " Release branch: ${{ env.RELEASE_BRANCH }}" | |
| echo " Release exists: ${{ env.RELEASE_EXISTS }}" | |
| echo " Event name: ${{ github.event_name }}" | |
| echo " Target Exists: ${{ env.TARGET_BRANCH_EXISTS }}" | |
| - name: Create version branch from master | |
| # ref.: https://github.com/peterjgrainger/action-create-branch, v3.0.0 | |
| # uses: peterjgrainger/action-create-branch@10c7d268152480ae859347db45dc69086cef1d9c | |
| # if: | | |
| # ( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) && | |
| # ( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) && | |
| # ( startsWith(env.RELEASE_BRANCH, 'release/v') && contains(env.RELEASE_BRANCH, '.') ) | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # with: | |
| # branch: ${{ env.RELEASE_BRANCH }} | |
| # sha: ${{ env.MASTER_REF }} | |
| if: | | |
| ( env.TARGET_BRANCH_EXISTS == 'false' ) && | |
| ( env.RELEASE_EXISTS == 'false' ) && | |
| startsWith(env.RELEASE_BRANCH, 'release/v') && | |
| contains(env.RELEASE_BRANCH, '.') | |
| run: | | |
| git fetch origin ${{ github.event.repository.default_branch }} | |
| git checkout -b ${{ env.RELEASE_BRANCH }} origin/${{ github.event.repository.default_branch }} | |
| git push https://x-access-token:${{ secrets.REPO_ACCESS }}@github.com/KiraCore/${{ github.event.repository.name }} ${{ env.RELEASE_BRANCH }} | |
| env: | |
| RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }} | |
| GITHUB_TOKEN: ${{ secrets.REPO_ACCESS }} | |
| - name: Create PR from feature to version branch | |
| # ref. repo-sync/pull-request is broken, using cea2aj/pull-request instead | |
| # TODO: cea2aj/pull-request abondoned, we need to switch back to peter-evans/create-pull-request | |
| uses: cea2aj/pull-request@84eb0c3478f13651e5649367941b867ca02d7926 | |
| # ref.: | |
| if: | | |
| ( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) && | |
| ( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) && | |
| ( startsWith(env.RELEASE_BRANCH, 'release/v') && contains(env.RELEASE_BRANCH, '.') ) | |
| with: | |
| github_token: ${{ secrets.REPO_ACCESS }} | |
| source_branch: ${{ env.SOURCE_BRANCH }} | |
| destination_branch: ${{ env.RELEASE_BRANCH}} | |
| pr_title: "${{ env.SOURCE_BRANCH }} -> ${{ env.RELEASE_BRANCH }}" | |
| pr_label: "kira-automation" | |
| pr_allow_empty: true | |