Skip to content

Post-Deploy

Post-Deploy #1

Workflow file for this run

name: Post-Deploy
on:
workflow_run:
workflows:
- Deploy
branches-ignore:
- 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 build_data.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_pr_on_brew_repo:
runs-on: ubuntu-20.04
needs: download_build_data_artifact
permissions:
contents: write
steps:
- name: Checkout Homebrew repo
uses: actions/checkout@v4
with:
repository: SystemCraftsman/homebrew-strimzi-kafka-cli
ref: refs/heads/master
token: ${{ secrets.GITHUB_TOKEN }}
- name: Apply changes
run: |
version="$(sed -n 's/version \"\(.*\)\"/\1/p' strimzi-kafka-cli.rb | sed -e 's/^[[:space:]]*//')"
sed -i -e "s/$version/${{ needs.download_build_data_artifact.outputs.image_version }}/g" strimzi-kafka-cli.rb
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ needs.download_build_data_artifact.outputs.image_version }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: version-update-${{ needs.download_build_data_artifact.outputs.image_version }}
assignees: mabulgu
reviewers: mabulgu
title: '[Automated PR] Update image tag and revision for prod upgrade'