Fix git tag creation and calico/go-build image tag #5
Workflow file for this run
This file contains 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 new Git branch on Go compiler version change | |
on: | |
# create a new go1.x branch and a release tag when changes are merged to the master branch | |
pull_request: | |
types: | |
- closed | |
branches: | |
- 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: Generate tag name | |
id: generate-tag-name | |
run: | | |
tag_name=$(hack/generate-version-tag-name.sh -f images/calico-go-build/versions.yaml) | |
echo "Git tag name: $tag_name" | |
echo "tag_name=$tag_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.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
git checkout -b "$branch_name" | |
git push origin "$branch_name" | |
echo "Created Git branch $branch_name" | |
tag_name=${{ steps.generate-tag-name.outputs.tag_name }} | |
git tag -a "$tag_name" -m "Release $tag_name" | |
git push origin "$tag_name" | |
echo "Created Git tag $tag_name" | |
fi |