Skip to content

Commit

Permalink
(chore)Fix the token expiry and move release version update code to a…
Browse files Browse the repository at this point in the history
… composite action (red-hat-data-services#1132)

Token expiry fix:
The installation token generated through the GH app has a validity of 1 hour.
ref: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app
So the issue is, when waiting for e2e tests(github checks) which runs for more than 1 hr to finish, the token gets expired and then the gh action is no longer
able to do other tasks(such as creating a pr)
In order to fix this, we can use the GITHUB_TOKEN that is generated for each workflow.
ref: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
The GITHUB_TOKEN expires when a job finishes or after a maximum of 24 hours.

Move version update to composite action:
There are 2 sets of steps in the job that does almost the same task. Instead of duplicating the steps, move it to a composite action and reuse the same.
  • Loading branch information
AjayJagan authored and zdtsw committed Aug 2, 2024
1 parent 242da53 commit cda9472
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/actions/update-release-version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Update release versions and create pr"
description: "Update versions in the manifests/makefile and create a pr"
inputs:
version:
description: 'The release version'
required: true
token:
description: "GH token with required rights to create pr"
required: true
commit-message:
description: "Commit message for the pr"
required: true
title:
description: "Title for the pr"
required: true
branch-name:
description: "Temporary branch to host the changes"
required: true
outputs:
pull-request-number:
description: "Number of the pull request created"
value: ${{ steps.cpr.outputs.pull-request-number }}
runs:
using: "composite"
steps:
- name: Update versions in relevant files
shell: bash
run: ./.github/scripts/update-versions.sh ${{ inputs.version }}
- name: Run make manifests & bundle
shell: bash
run: make manifests bundle
- name: Clean up
shell: bash
run: |
sed -i -e "s|image: quay.io/opendatahub/opendatahub-operator:latest.*|image: REPLACE_IMAGE:latest|g" bundle/manifests/opendatahub-operator.clusterserviceversion.yaml
rm ./config/manager/kustomization.yaml
- name: Create pr
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ inputs.token }}
commit-message: ${{ inputs.commit-message }}
branch: ${{ inputs.branch-name }}
delete-branch: true
title: ${{ inputs.title }}
reviewers: "VaishnaviHire,zdtsw"
- name: Set pr number in output
shell: bash
run: |
echo "pull-request-number=${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_OUTPUT"

0 comments on commit cda9472

Please sign in to comment.