Skip to content

Commit

Permalink
add pre deploy action yaml (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
mabulgu committed Nov 21, 2023
1 parent f6068fd commit dc474bf
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ jobs:
make test
- name: Build
run: make build

upload_build_data_artifact:
runs-on: ubuntu-latest
needs: build
steps:
- name: Write image version
run: |
printf '{
"image_version": "19.0.0"
}' >> build_data.json
- uses: actions/upload-artifact@v3
with:
name: build_data.json
path: ./
80 changes: 80 additions & 0 deletions .github/workflows/pre_deploy_actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Create Ops PR
on:
workflow_run:
workflows:
- Build
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 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'

0 comments on commit dc474bf

Please sign in to comment.