Changes for nm update
This commit is contained in:
parent
a9c6b10351
commit
d9c90c5e98
99
.github/wip/nm-update-push_2.yml
vendored
Normal file
99
.github/wip/nm-update-push_2.yml
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
name: Deployed Dev
|
||||
run-name: Deploying ${{ github.ref_name }} to ${{ github.event.inputs.env || 'dev' }}
|
||||
|
||||
on:
|
||||
# workflow_run: Doesn't work in gitea
|
||||
# workflows: [Update Repo Version]
|
||||
# types:
|
||||
# - completed
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+' # Push events to every tag
|
||||
workflow_dispatch:
|
||||
# inputs:
|
||||
# version:
|
||||
# type: string
|
||||
# description: Version of cs-repo to deploy
|
||||
# required: false
|
||||
# nm-dev:
|
||||
# type: boolean
|
||||
# description: Deploy to dev?
|
||||
# default: true
|
||||
# nm-rc:
|
||||
# type: boolean
|
||||
# description: Deploy to rc?
|
||||
# nm-prod:
|
||||
# type: boolean
|
||||
# description: Deploy to prod?
|
||||
# env:
|
||||
# description: "Env to deploy to"
|
||||
# required: true
|
||||
# default: "dev"
|
||||
# type: choice
|
||||
# options:
|
||||
# - dev
|
||||
# - rc
|
||||
# - prod
|
||||
|
||||
env:
|
||||
NM_ENV: nm-dev
|
||||
CS_REPO: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
push-cs-update:
|
||||
runs-on: ubuntu-22.04
|
||||
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
|
||||
token: ${{ github.token }}
|
||||
|
||||
- name: Checkout nm repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.NM_ENV }}
|
||||
ref: main
|
||||
path: nm
|
||||
token: ${{ github.token }}
|
||||
|
||||
|
||||
- name: Checkout deploy-tools
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: gmetribin/deploy-tools
|
||||
ref: main
|
||||
path: deploy-tools
|
||||
token: ${{ github.token }}
|
||||
|
||||
- name: Increment cs version in nm repo and push
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
git config --global user.name 'bot-build'
|
||||
git config --global user.email 'techbots+build@gmetri.com'
|
||||
|
||||
cd cs;
|
||||
VERSION=`git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*"`;
|
||||
cd ../nm;
|
||||
CS_LIST=./.github/cslist.txt
|
||||
|
||||
pwd; ls -al;
|
||||
|
||||
cd nm;
|
||||
../deploy-tools/src/cs_to_nm.sh -c ${{ env.CS_REPO }} -v $VERSION -k $CS_LIST;
|
||||
|
||||
git push origin main;
|
||||
14
.github/workflows/cs-update-push.yml
vendored
14
.github/workflows/cs-update-push.yml
vendored
@ -31,7 +31,8 @@ jobs:
|
||||
echo "BUILD_ID: ${{ steps.read-issue.outputs.BUILD_ID }}";
|
||||
echo "DOCKER_BASE: ${{ steps.read-issue.outputs.DOCKER_BASE }}";
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout cs repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: cs
|
||||
token: ${{ secrets.bot_build_repo_token }} #This is because we want to trigger a new build
|
||||
@ -42,12 +43,9 @@ jobs:
|
||||
repository: gmetribin/deploy-tools
|
||||
ref: main
|
||||
path: deploy-tools
|
||||
token: ${{ github.token }}
|
||||
token: ${{ github.token }} #Any pushes with github.token don't trigger a chained build
|
||||
|
||||
- name: Increment package version and push
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||
# GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
git config --global user.name 'bot-build'
|
||||
git config --global user.email 'techbots+build@gmetri.com'
|
||||
@ -58,7 +56,7 @@ jobs:
|
||||
pwd; ls -al;
|
||||
|
||||
cd cs;
|
||||
../deploy-tools/src/repo_to_cs.sh -m $DOCKER_BASE -t $BUILD_ID -r $REPOLIST
|
||||
../deploy-tools/src/repo_to_cs.sh -m $DOCKER_BASE -t $BUILD_ID -r $REPOLIST;
|
||||
|
||||
git push origin main
|
||||
git push --tags origin main
|
||||
git push origin main;
|
||||
git push --tags origin main;
|
||||
|
||||
4
.github/workflows/cs-update-trigger.yml
vendored
4
.github/workflows/cs-update-trigger.yml
vendored
@ -11,7 +11,7 @@ on:
|
||||
type: string
|
||||
|
||||
env:
|
||||
REPO: ${{ github.repository }}
|
||||
CS_REPO: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
trigger-cs-job:
|
||||
@ -24,7 +24,7 @@ jobs:
|
||||
run: |
|
||||
SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }};
|
||||
BUILD_ID=$BRANCH_NAME-${SHA:0:8};
|
||||
DOCKER_BASE=${{ vars.docker_repo2_registry }}/$REPO
|
||||
DOCKER_BASE=${{ vars.docker_repo2_registry }}/$CS_REPO
|
||||
DOCKER_IMAGE=$DOCKER_BASE:$BUILD_ID;
|
||||
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||
echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT";
|
||||
|
||||
@ -4,24 +4,19 @@
|
||||
### Functions
|
||||
usage()
|
||||
{
|
||||
echo "usage: $0 [-n nm-repo -c cs-repo -v version] | [-h]"
|
||||
echo "usage: $0 [-c cs-repo -v version] | [-h]"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
local NM_REPO_NAME=$1
|
||||
local CS_REPO_NAME=$2
|
||||
local VERSION=$3
|
||||
|
||||
rm -rf nm-repo
|
||||
git clone https://git.gmetri.io/gmetrivr/$NM_REPO_NAME.git nm-repo
|
||||
cd nm-repo
|
||||
|
||||
local CS_REPO_NAME=$1
|
||||
local VERSION=$2
|
||||
|
||||
#Get list of repos from cslist.txt
|
||||
# Example lines in file:
|
||||
#cs-brx mat81-dev/brx/brx-2jitsi/kustomization.yaml cs-brx.git\/\/brx\/brx-2jitsi?ref=
|
||||
#cs-brx mat81-dev/brx/brx-3main/kustomization.yaml cs-brx.git\/\/brx\/brx-3main?ref=
|
||||
CSLIST_PATH="./c/cslist.txt"
|
||||
CSLIST_PATH="./.github/cslist.txt"
|
||||
CSLIST=$(cat $CSLIST_PATH | grep ^$CS_REPO_NAME | tr -s " " | awk -v FS=' ' -v OFS='\t' '/^[^#]/' )
|
||||
echo "$CSLIST" #doublequote preserves the shape of the input variable, including endlines
|
||||
if [ -z "$CSLIST" ]
|
||||
@ -39,16 +34,12 @@ main()
|
||||
git add $KUST_PATH
|
||||
done <<< "$CSLIST"
|
||||
|
||||
git commit -m "$NM_REPO_NAME updated with $CS_REPO_NAME: $VERSION"
|
||||
git push origin master
|
||||
git commit -m "$CS_REPO_NAME updated to $VERSION"
|
||||
}
|
||||
|
||||
### Starts here
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-n | --nm-repo ) shift
|
||||
NM_REPO_NAME=$1
|
||||
;;
|
||||
-c | --cs-repo ) shift
|
||||
CS_REPO_NAME=$1
|
||||
;;
|
||||
@ -64,11 +55,11 @@ while [ "$1" != "" ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $NM_REPO_NAME || -z $CS_REPO_NAME || -z $VERSION ]]
|
||||
if [[ -z $CS_REPO_NAME || -z $VERSION ]]
|
||||
then
|
||||
echo "Not enough arguments"
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
main "$NM_REPO_NAME" "$CS_REPO_NAME" "$VERSION"
|
||||
main "$CS_REPO_NAME" "$VERSION"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user