Remote workflow

This commit is contained in:
Sahil Ahuja 2025-02-10 12:18:33 +05:30
parent 3e5a503770
commit 8a615ceb52

81
.github/workflows/nm-update.yml vendored Normal file
View File

@ -0,0 +1,81 @@
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:
NM_ENV: gmetrivr/nm-dev
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_ENV=${{ env.NM_ENV }}
- 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: ${{ env.NM_ENV }}
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.11
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 push origin main;