From 8a615ceb52deb03e67ee07d36b61ae97e72dfde5 Mon Sep 17 00:00:00 2001 From: Sahil Ahuja Date: Mon, 10 Feb 2025 12:18:33 +0530 Subject: [PATCH] Remote workflow --- .github/workflows/nm-update.yml | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/nm-update.yml diff --git a/.github/workflows/nm-update.yml b/.github/workflows/nm-update.yml new file mode 100644 index 0000000..bdf3184 --- /dev/null +++ b/.github/workflows/nm-update.yml @@ -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;