Create Ops PR #1
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 Ops PR | |
on: | |
workflow_run: | |
workflows: | |
- Build | |
branches: | |
- main | |
types: | |
- completed | |
jobs: | |
download_build_data_artifact: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "build_data.json" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/build_data.zip`, Buffer.from(download.data)); | |
- name: Unzip artifact | |
run: unzip context.zip | |
- name: Return Parsed JSON | |
uses: actions/github-script@v6 | |
id: return-parsed-json | |
with: | |
script: | | |
let fs = require('fs'); | |
let data = fs.readFileSync('./build_data.json'); | |
return JSON.parse(data); | |
outputs: | |
image_version: ${{ fromJSON(steps.return-parsed-json.outputs.result).image_version }} | |
create_ops_pr: | |
name: Create Ops PR | |
runs-on: ubuntu-20.04 | |
needs: download_build_data_artifact | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Ops repo | |
uses: actions/checkout@v4 | |
with: | |
repository: SystemCraftsman/homebrew-strimzi-kafka-cli | |
ref: main | |
- name: Apply changes | |
run: | | |
echo "${{ needs.download_build_data_artifact.outputs.image_version }}" > test.txt | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: Update image tag and revision for prod upgrade | |
committer: GitHub <noreply@github.com> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
branch: prod-upgrade-${{ needs.download_build_data_artifact.outputs.image_version }} | |
assignees: mabulgu | |
reviewers: mabulgu | |
title: '[Automated PR] Update image tag and revision for prod upgrade' |