Skip to content

chore: add plz run workflow #355

chore: add plz run workflow

chore: add plz run workflow #355

Workflow file for this run

name: 'ci'
on:
pull_request:
branches:
- develop
- main
push:
branches:
- develop
- main
- 'release/**'
- 'hotfix/**'
env:
GITVERSION_CONFIG_MONOREPO: '.cicd/common/.gitversion.yml'
PROJECT_NAME: payobills
jobs:
ci:
name: ci
runs-on: ubuntu-22.04
steps:
- name: Setup please.build
uses: sagikazarmark/setup-please-action@v0
- name: Checkout
uses: actions/checkout@v2
- name: Fetch all history for all tags and branches
run: |
git fetch --unshallow
git checkout main && git checkout -
- name: Checkout to branch
uses: mrsauravsahu/monotools/apps/semver-yeasy@main
with:
repo-type: MONOREPO
mode: checkout
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install GitVersion.Tool
run: dotnet tool install --global GitVersion.Tool --version 5.12.0
- uses: actions/cache@v2
with:
path: plz-out
key: plz-out
- name: Calculate changed services
id: calculate_changed_services
uses: mrsauravsahu/monotools/apps/semver-yeasy@main
with:
repo-type: MONOREPO
mode: changed
- name: Generate other targets
id: generate_other_targets
env:
SERVICES_RAW: ${{ steps.calculate_changed_services.outputs.changed_services }}
run: |
echo "SERVICES_RAW='${SERVICES_RAW}'"
SERVICES=($(echo "${SERVICES_RAW}" | jq -r '.value[]'))
echo "SERVICES='${SERVICES[@]}'"
DOCKER_BUILD_TARGETS=($(echo "${SERVICES[@]}" | xargs printf "//%s:docker "))
IMAGE_SCAN_TARGETS=($(echo "${SERVICES[@]}" | xargs printf "//%s:image_scan "))
echo "DOCKER_BUILD_TARGETS='${DOCKER_BUILD_TARGETS[@]}'"
echo "IMAGE_SCAN_TARGETS='${IMAGE_SCAN_TARGETS[@]}'"
echo "DOCKER_BUILD_TARGETS=\"${DOCKER_BUILD_TARGETS[@]}\"" >> $GITHUB_OUTPUT
echo "IMAGE_SCAN_TARGETS=\"${IMAGE_SCAN_TARGETS[@]}\"" >> $GITHUB_OUTPUT
changed_services=$(printf '%s' "$SERVICES" | jq --raw-input --slurp '.')
echo "SERVICES='${SERVICES[@]}'" >> $GITHUB_OUTPUT
# - name: lint targets
# if: steps.generate_other_targets.outputs.SERVICES != ''
# run: |
# # TODO: figure out how to pass different env for different targets
# for i in ${{ steps.generate_other_targets.outputs.SERVICES }}; do
# PLZ_OVERRIDES=buildenv.SECRET_SERVICE_NAME:"$i" plz run $i:lint
# done
# - name: run tests
# if: steps.generate_other_targets.outputs.SERVICES_SINGLE_LINE != ''
# run: plz test `echo ${{ steps.generate_other_targets.outputs.SERVICES_SINGLE_LINE }} | sed 's|//apps/[a-z]*|&/tests|g'`
# - name: Build targets
# if: steps.calculate_changed_services.outputs.changed_services != ''
# run: echo ${{ steps.generate_other_targets.outputs.DOCKER_BUILD_TARGETS }} | xargs plz run parallel
# - name: Container Scanning
# if: steps.calculate_changed_services.outputs.changed_services != ''
# run: echo ${{ steps.generate_other_targets.outputs.IMAGE_SCAN_TARGETS }} | xargs -n 1 sh -c 'echo $0; echo ----; plz run $0; echo ----;'
- name: Calculate versions
id: calculate_service_versions
env:
GITVERSION_EXEC_PATH: /home/runner/.dotnet/tools/dotnet-gitversion
JQ_EXEC_PATH: /usr/bin/jq
SEMVERYEASY_CHANGED_SERVICES: ${{ fromJSON(steps.generate_other_targets.outputs.SERVICES) }}
GITVERSION_CONFIG_MONOREPO: ${{ env.GITVERSION_CONFIG_MONOREPO }}
uses: mrsauravsahu/monotools/apps/semver-yeasy@main
with:
repo-type: MONOREPO
mode: calculate-version
diff_source: ${{ steps.calculate_changed_services.outputs.diff_source }}
diff_dest: ${{ steps.calculate_changed_services.outputs.diff_dest }}
- name: Update PR description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEMVERY_YEASY_PR_BODY: ${{ steps.calculate_service_versions.outputs.PR_BODY }}
if: ${{ github.event_name == 'pull_request' }}
uses: mrsauravsahu/monotools/apps/semver-yeasy@main
with:
repo-type: MONOREPO
mode: update-pr
diff_source: ${{ steps.calculate_changed_services.outputs.diff_source }}
diff_dest: ${{ steps.calculate_changed_services.outputs.diff_dest }}
- name: Tag build
if: ${{ github.event_name == 'push' && (steps.calculate_changed_services.outputs.diff_dest == 'main' && startsWith(steps.calculate_changed_services.outputs.diff_dest, 'release') || startsWith(steps.calculate_changed_services.outputs.diff_dest, 'hotfix')) && steps.calculate_changed_services.outputs.changed_services != '' }}
env:
SEMVERYEASY_CHANGED: ${{ steps.calculate_changed_services.outputs.changed }}
SEMVERYEASY_CHANGED_SERVICES: ${{ steps.generate_other_targets.outputs.SERVICES }}
uses: mrsauravsahu/monotools/apps/semver-yeasy@main
with:
repo-type: MONOREPO
mode: tag
diff_dest: ${{ steps.calculate_changed_services.outputs.diff_dest }}