2025-03-06 23:11:04 +05:30

83 lines
2.3 KiB
YAML

name: Deploy to an environment
run-name: Deploying ${{ github.ref_name }} to ${{ github.event.inputs.env || 'dev' }}
on:
workflow_call:
secrets:
bot_build_repo_token:
required: true
inputs:
nm_repo:
description: 'The nm repo to be deployed'
required: true
type: string
# workflow_run: Doesn't work in gitea
# workflows: [Update Repo Version]
# types:
# - completed
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+' # Push events on every tag
# workflow_dispatch:
env:
CS_REPO: ${{ github.repository }}
jobs:
nm-update:
runs-on: ubuntu-22.04
if: ${{ github.ref_type == 'tag' }}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- id: read-inputs
name: Read the inputs in dispatch
run: |
set -x
TAG_NAME=${{ github.ref_name }}
REF_NAME=${{ github.event.ref }}
nm_repo=${{ inputs.nm_repo }}
- name: Checkout cs repo
uses: actions/checkout@v4
with:
path: cs
- name: Checkout nm repo
uses: actions/checkout@v4
with:
github-server-url: ${{ github.server_url }}
repository: ${{ inputs.nm_repo }}
ref: main
path: nm
token: ${{ secrets.bot_build_repo_token }} #This is because we want to trigger a new build
# token: $\{{ github.token }} # DEFAULT / Any pushes with github.token don't trigger a chained build
- name: Checkout deploy-tools
uses: actions/checkout@v4
with:
github-server-url: ${{ github.server_url }}
repository: gmetribin/deploy-tools
ref: v1.1.37
path: deploy-tools
- name: Increment cs version in nm repo and push
run: |
git config --global user.name 'bot-build'
git config --global user.email 'techbots+build@gmetri.com'
pwd; ls -al;
cd cs;
VERSION=`git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*"`;
cd ..;
cd nm;
CS_LIST=./.github/cslist.txt;
../deploy-tools/src/cs_to_nm.sh -c ${{ env.CS_REPO }} -v $VERSION -k $CS_LIST;
git commit -m "$CS_REPO_NAME to $VERSION by ${{ github.event.sender.login }}"
git push origin main;