Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre deploy action yaml #116

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'