Skip to content

Use tigera-marvin github token for actions #3

Use tigera-marvin github token for actions

Use tigera-marvin github token for actions #3

name: Create new Git branch on Go compiler version change
on:
pull_request:
types:
- closed
branches:
# create a new go1.x branch when changes to golang version are merged
# to the master branch
- master
jobs:
create-branch:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate Go branch name
id: generate-go-branch-name
run: |
branch_name=$(hack/generate-go-branch-name.sh -f images/calico-go-build/versions.yaml)
echo "Git branch name: $branch_name"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
- name: Create and push new branch (if not exists)
run: |
branch_name=${{ steps.generate-go-branch-name.outputs.branch_name }}
if git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then
echo "Git branch $branch_name already exists"
else
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.MARVIN_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git checkout -b "$branch_name"
git push origin "$branch_name"
echo "Created Git branch $branch_name"
fi