Build infra-repo #239
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: Build infra-repo | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- release-v*[0-9].*[0-9].x | |
- master | |
paths: | |
- "infra-repo/**" | |
- "box-chart/**" | |
push: | |
tags: | |
- "*-infra-repo" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Helm | |
uses: azure/[email protected] | |
with: | |
version: v3.5.0 | |
- name: Copy box-chart into build context | |
run: | | |
cp -r ./box-chart ./infra-repo/ | |
- name: set up docker buildx plugin | |
uses: docker/setup-buildx-action@v2 | |
- name: log in to github container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Read infra version | |
id: chart | |
uses: actions-tools/yaml-outputs@v2 | |
with: | |
file-path: "./chart/Chart.yaml" | |
- name: build image & push to registry | |
id: build | |
uses: docker/build-push-action@v3 | |
with: | |
file: ./infra-repo/Dockerfile | |
context: ./infra-repo/ | |
push: true | |
tags: ghcr.io/th2-net/infra-repo:${{ steps.chart.outputs.version }} | |
cache-from: type=registry,ref=ghcr.io/th2-net/infra-repo:${{ steps.chart.outputs.version }} | |
- name: Update values | |
run: | | |
updated=$(yq '.infraRepo.image.tag = "${{ steps.chart.outputs.version }}@${{ steps.build.outputs.digest }}"' chart/values.yaml) | |
noBlanks=$(yq '.' chart/values.yaml) | |
patch --no-backup-if-mismatch chart/values.yaml <(diff -B <(echo "$noBlanks") <(echo "$updated")) | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: "${{ secrets.TH2_NET_CI_PRIVATE_ACTION }}" | |
commit-message: Bump infra-repo | |
committer: GitHub <[email protected]> | |
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" | |
base: "${{ github.event.pull_request.head.ref }}" | |
branch: infra-repo-${{ github.event.pull_request.head.ref }} | |
milestone: "${{ github.event.pull_request.milestone.title }}" | |
delete-branch: true | |
title: "[${{ github.event.pull_request.milestone.title }}][Auto] Build and bump infra-repo" | |
body: "Bump infra-repo to ${{ steps.chart.outputs.version }}@${{ steps.build.outputs.digest }}" | |
labels: automated |