Skip to content

Commit

Permalink
Run docker build and update version tags
Browse files Browse the repository at this point in the history
  • Loading branch information
unkhz committed Jul 19, 2024
1 parent ea9f859 commit 33cefea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 47 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,20 @@ name: Build package
on:
workflow_call:
inputs:
package:
required: true
type: string
context:
required: true
type: string
image:
required: true
type: string
kustomization:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
continue-on-error: true

strategy:
matrix:
node-version: [20]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup node 20
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Run npm install
run: npm install

- name: Run node build
run: npx nx run-many --projects=${{ inputs.package }} --target=$node:build --output-style=stream

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -57,16 +33,3 @@ jobs:
context: ${{ inputs.context }}
push: true
tags: ${{ inputs.image }}:latest, ${{ inputs.image }}:${{ github.sha }}

- uses: mikefarah/yq@master
with:
cmd: yq --version

- name: Update image version tag
run: |
git config --global user.email "juhani.pelli@gmail.com"
git config --global user.name "Juhani Pelli"
yq e '.images[0].newTag = "${{ github.sha }}"' -i ${{ inputs.kustomization }}
git add ${{ inputs.kustomization }}
git commit -m "Deploy ${{ github.sha }} [skip ci]"
git push origin ${{ github.event.repository.default_branch }}
38 changes: 28 additions & 10 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,13 @@ jobs:
strategy:
matrix:
args:
- package: base-node
context: .
- context: .
image: ghcr.io/unkhz/ruuvipuserrin-base-node
kustomization: ./packages/base-node/.khz-k3s/kustomization.yaml

uses: ./.github/workflows/build-package.yml
with:
package: ${{ matrix.args.package }}
context: ${{ matrix.args.context }}
image: ${{ matrix.args.image }}
kustomization: ${{ matrix.args.kustomization }}

build-package-images:
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }}
Expand All @@ -73,14 +69,36 @@ jobs:
strategy:
matrix:
args:
- package: archive
context: ./packages/archive
- context: ./packages/archive
image: ghcr.io/unkhz/ruuvipuserrin-archive
kustomization: ./packages/archive/.khz-k3s/kustomization.yaml

uses: ./.github/workflows/build-package.yml
with:
package: ${{ matrix.args.package }}
context: ${{ matrix.args.context }}
image: ${{ matrix.args.image }}
kustomization: ${{ matrix.args.kustomization }}

update-version-tags:
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
needs: build-package-images

strategy:
matrix:
kustomization:
- ./packages/base-node/.khz-k3s/kustomization.yaml
- ./packages/archive/.khz-k3s/kustomization.yaml

steps:
- name: Install yq
uses: mikefarah/yq@master
with:
cmd: yq --version

- name: Update image version tag
run: |
git config --global user.email "juhani.pelli@gmail.com"
git config --global user.name "Juhani Pelli"
yq e '.images[0].newTag = "${{ github.sha }}"' -i ${{ matrix.kustomization }}
git add ${{ matrix.kustomization }}
git commit -m "Deploy ${{ github.sha }} [skip ci]"
git push origin ${{ github.event.repository.default_branch }}

0 comments on commit 33cefea

Please sign in to comment.