Skip to content

Commit

Permalink
Simplify the create-pr workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
  • Loading branch information
lcarva committed Oct 14, 2024
1 parent 7e7b11f commit b5daa84
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/create-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,23 @@ jobs:
run: git diff
working-directory: infra-deployments

- name: Checkout infra-deployments-ci
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
id: generate-token
with:
path: infra-deployments-ci

- name: Create PR in infra-deployments
env:
EC_AUTOMATION_KEY: ${{ secrets.EC_AUTOMATION_KEY }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
APP_INSTALL_ID: 32872589
run: |
set -o errexit
set -o pipefail
set -o nounset
app-id: ${{ vars.EC_AUTOMATION_APP_ID }}
private-key: ${{ secrets.EC_AUTOMATION_KEY }}

function createJWT() {
local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local now_utc=$(date --utc +%s)
local payload=$(echo -n '{"iat":'$((now_utc - 60))',"exp":'$((now_utc + 120))',"iss":245286}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local signature=$(echo -n "${header}.${payload}" | openssl dgst -sha256 -binary -sign <(echo "${EC_AUTOMATION_KEY}")| base64 | tr -d '\n=' | tr -- '+/' '-_')
echo "${header}.${payload}.${signature}"
}
GITHUB_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $(createJWT)" -H "Accept: application/vnd.github+json" "https://api.github.com/app/installations/${APP_INSTALL_ID}/access_tokens" | jq -r .token) \
./hack/create-pr.sh git@github.com:enterprise-contract/infra-deployments.git ../infra-deployments
working-directory: infra-deployments-ci
- name: pull-request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
branch: ci/update-go-containerregistry
commit-message: enterprise contract update
sign-commits: true
signoff: true
title: enterprise contract update
token: ${{ steps.generate-token.outputs.token }}
push-to-fork: enterprise-contract/infra-deployments
path: infra-deployments

create-build-definitions-pr:
if: >
Expand Down

0 comments on commit b5daa84

Please sign in to comment.