Skip to content

Execute new-patch for version 1.22 #237

Execute new-patch for version 1.22

Execute new-patch for version 1.22 #237

name: Automated Release Actions
run-name: Execute ${{ github.event.inputs.action || 'update-upstream-versions' }} for version ${{ github.event.inputs.version || 'next' }}
on:
schedule:
- cron: "0 0 * * *" # At every day at 00
workflow_dispatch:
inputs:
action:
description: 'Select Action (see README for details)'
required: true
type: choice
options:
- new-release
- new-patch
- update-upstream-versions
version:
description: |
Downstream Release Version. Eg: "1.22", "1.23", "next"
required: true
type: string
permissions:
contents: write
pull-requests: write
jobs:
run-release:
runs-on: ubuntu-latest
env:
# NOTE: in case of update, the defaults here are also specified in the run-name
ACTION: ${{ github.event.inputs.action || 'update-upstream-versions' }}
VERSION: ${{ github.event.inputs.version || 'next' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Debug inputs
run: |
echo "Action: $ACTION"
echo "Version: $VERSION"
- name: Run Release Script
env:
GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
GITHUB_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
run: |
./hack/release-manager.sh \
--action "$ACTION" \
--version "$VERSION"
- name: Create Pull Request
id: create_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
git config user.name openshift-pipelines-bot
git config user.email pipelines-extcomm@redhat.com
BASE_BRANCH=${GITHUB_REF#refs/heads/}
SOURCE_BRANCH=actions/$BASE_BRANCH/$ACTION-$VERSION
git checkout -b ${SOURCE_BRANCH}
git add -f config .github
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
ACTOR="schedule"
# The workflow's "actor" is weird when the workflow is scheduled
# See: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#actor-for-scheduled-workflows
[[ "${GITHUB_EVENT_NAME}" != "schedule" ]] && ACTOR="${GITHUB_TRIGGERING_ACTOR}"
git commit -F- <<EOF
[bot: $VERSION] Release Action: $ACTION
Generated by workflow [${GITHUB_WORKFLOW}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})
Triggered by ${ACTOR}
EOF
git push -f origin ${SOURCE_BRANCH}
if [ "$(gh pr list --base ${BASE_BRANCH} --head ${SOURCE_BRANCH} --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
PR_URL=$(gh pr create -B ${BASE_BRANCH} -H ${SOURCE_BRANCH} --label=automated --fill)
echo "url=${PR_URL}" >> "$GITHUB_OUTPUT"
fi
- name: Generate Summary
env:
PR_URL: ${{ steps.create_pr.outputs.url }}-
run: |
if [[ -n "${PR_URL}" ]]; then
echo "Opened Pull Request: ${PR_URL}" >> $GITHUB_STEP_SUMMARY
else
echo "No changed detected, no PR generated" >> $GITHUB_STEP_SUMMARY
fi