Skip to content

fix: refactor to suffix -service to service folders #5

fix: refactor to suffix -service to service folders

fix: refactor to suffix -service to service folders #5

Workflow file for this run

name: "Build and push"
on:
push:
branches: [ main ]
env:
GO_VERSION: "1.24.4"
jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/setup-go@v4
# with:
# go-version: "${{ env.GO_VERSION }}"
# cache: false
# - uses: actions/checkout@v4
# - name: go-lint
# uses: golangci/golangci-lint-action@v3
# with:
# version: latest
# args: --timeout 5m0s
# Detect services that need to be built via the builder
detect-services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.detect-services.outputs.services }}
steps:
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- uses: actions/checkout@v4
with:
fetch-depth: '0'
# Setup Go so we can run the builder
- name: detect-services
id: detect-services
env:
GH_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
services=$(go run builder/main.go)
echo "Raw services output: $services"
echo "services=$services" >> $GITHUB_OUTPUT
- name: print-services
run: |
echo "Services: ${{ steps.detect-services.outputs.services }}"
build-and-publish:
needs: [ detect-services ]
if: needs.detect-services.outputs.services != '[]' # Only run if there are services to build
runs-on: ubuntu-latest
strategy:
matrix:
service: ${{ fromJson(needs.detect-services.outputs.services) }}
steps:
- name: Import Secrets
uses: hollow-cube/actions/secrets@main
with:
token: ${{ secrets.VAULT_TOKEN }}
path: global/github
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
- uses: ko-build/setup-ko@v0.6
env:
KO_DOCKER_REPO: mworzala
- name: Build image
shell: bash
run: |
ko login docker.io --username mworzala --password ${{ env.DOCKER_PASS }}
ko build ./services/${{ matrix.service }}/cmd/${{ matrix.service }} --base-import-paths --tags ${{ github.sha }} --platform linux/amd64
echo "Version: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
# todo this needs to change for HollowCube deploys.
# deploy:
# needs: [build-and-publish, detect-services]
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main' # Only run on main branch
# env:
# SERVICES: ${{ needs.detect-services.outputs.services }}
# steps:
# - name: "Checkout deployments repo"
# uses: "actions/checkout@v4"
# with:
# repository: "nimbus-mc/argocd-deployments"
# ref: "main"
# token: "${{ secrets.DEPLOYMENTS_REPO_TOKEN }}"
#
# - name: "Update image version"
# shell: "bash"
# # git commit -a automatically adds files that have been modified
# env:
# PUSH_TOKEN: "${{ secrets.DEPLOYMENTS_REPO_TOKEN }}"
# run: |
# echo "Services: $SERVICES"
#
# services_array=($(echo $SERVICES | jq -r '.[]'))
#
# git config --global user.name "github-actions[bot]"
# git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
#
# for service in "${services_array[@]}"; do
# serviceValuesPath="services/values/$service.yaml"
#
# echo "Updating image for $service to ${{ github.sha }} at $serviceValuesPath"
# sed -i "s|version: .*|version: ${{ github.sha }}|g" $serviceValuesPath
# git commit -a -m "Update $service to ${{ github.sha }}"
# done
#
# git push https://😛:$PUSH_TOKEN@github.com/nimbus-mc/argocd-deployments.git