Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d67ad21b7d | ||
|
|
4aec3cdb78 | ||
|
|
ddd5f59c18 | ||
|
|
98843f44f6 | ||
|
|
a24a7ce927 | ||
|
|
7cbbb82805 | ||
|
|
45b7982a4c | ||
|
|
ae65162eb4 | ||
|
|
58708425fd | ||
|
|
c214aac69d | ||
|
|
edeaa7f7c0 | ||
|
|
5d6a43a007 | ||
|
|
298c951b19 | ||
|
|
88ab0abceb | ||
|
|
7cc7edaee6 | ||
|
|
23a90586b2 | ||
|
|
2c91e942b2 | ||
|
|
776661b372 | ||
|
|
e1780938ad | ||
|
|
b74044d1f5 | ||
|
|
2e13dc6ba4 | ||
|
|
c8322be7a1 | ||
|
|
6ce9375618 | ||
|
|
a608f6b4d6 | ||
|
|
22c46d4e24 | ||
|
|
93fbb5c9f7 | ||
|
|
2696bd5f1d | ||
|
|
e1e8faa21e | ||
|
|
4c36c5ac34 | ||
|
|
8ad08afcf4 | ||
|
|
76e3873f79 | ||
|
|
68e604c41a | ||
|
|
011b6fecc4 | ||
|
|
6f12bd895b | ||
|
|
ef9622e749 | ||
|
|
d0c7a8f855 | ||
|
|
27635d5be0 | ||
|
|
8a615ceb52 | ||
|
|
3e5a503770 | ||
|
|
4205d67f5b | ||
|
|
ea758d77aa | ||
|
|
d9c90c5e98 | ||
|
|
a9c6b10351 | ||
|
|
45cdb46d40 | ||
|
|
7cd1f4460f | ||
|
|
ee6d667b0e |
99
.github/unused/nm-update-push_2.yml
vendored
Normal file
99
.github/unused/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;
|
||||
78
.github/unused/sh/trigger.sh
vendored
Normal file
78
.github/unused/sh/trigger.sh
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
curl -L \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "Authorization: Bearer <YOUR-TOKEN>"\
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
|
||||
-d '{"ref":"main","inputs":{"image":"${{ inputs.image }}","tag":"${{ inputs.tag }}"}}';
|
||||
|
||||
repo2.hub.gmetri.io/dt-api
|
||||
main-fda468af
|
||||
|
||||
Token (DUMMY): e139b1c73bfae1b7748961c9f9a381bd3cca0633
|
||||
|
||||
|
||||
https://git.gmetri.io/gmetrivr/cs-dt/actions/run?workflow=update-repo-version.yml&actor=0&status=
|
||||
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"assignee": "bot-build",
|
||||
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}",
|
||||
"closed": false,
|
||||
"title": "cs-dt package for repo2.hub.gmetri.io/dt-api:main-fda468af"
|
||||
}'
|
||||
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-d '{
|
||||
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}"
|
||||
}'
|
||||
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"body": "{\"image\":\"repo2.hub.gmetri.io\/dt-api\",\"tag\":\"main-255c2f30\"}"
|
||||
}'
|
||||
|
||||
ISSUE_COMMENT_STRING=`echo '{ "image": "repo2.hub.gmetri.io/dt-api", "tag": "main-255c2f30" }' | jq tostring`
|
||||
API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring`
|
||||
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
|
||||
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d $API_JSON_BODY
|
||||
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}'
|
||||
|
||||
#Get the latest issue with label workflow
|
||||
ISSUE_JSON=`curl -X 'GET' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-ui/issues?labels=workflow&page=1&limit=1' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token 20daafd0fb3dd3392738430bf438eb96023b5cb0'`
|
||||
ISSUE_NUMBER=`echo $ISSUE_JSON | jq '.[0].number'`
|
||||
curl -X 'POST' \
|
||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/$ISSUE_NUMBER/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}'
|
||||
60
.github/workflows/cs-update-push.yml
vendored
60
.github/workflows/cs-update-push.yml
vendored
@ -2,6 +2,9 @@ name: Update Repo Version Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
bot_build_repo_token:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
|
||||
@ -18,43 +21,66 @@ jobs:
|
||||
name: Read the issue comment
|
||||
run: |
|
||||
ISSUE_COMMENT_STRING='${{ github.event.comment.body }}'
|
||||
DOCKER_BASE=`echo $ISSUE_COMMENT_STRING | jq ".image"`
|
||||
BUILD_ID=`echo $ISSUE_COMMENT_STRING | jq ".tag"`
|
||||
echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT";
|
||||
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||
TAG=`echo $ISSUE_COMMENT_STRING | jq -r ".tag"`
|
||||
REPO=`echo $ISSUE_COMMENT_STRING | jq -r ".repo"`
|
||||
SENDER=`echo $ISSUE_COMMENT_STRING | jq -r ".sender"`
|
||||
|
||||
# Try to extract docker_repo from issue comment, fallback to default variable
|
||||
DOCKER_REPO_FROM_COMMENT=`echo $ISSUE_COMMENT_STRING | jq -r ".docker_repo"`
|
||||
if [ -n "$DOCKER_REPO_FROM_COMMENT" ] && [ "$DOCKER_REPO_FROM_COMMENT" != "null" ]; then
|
||||
DOCKER_REPO=$DOCKER_REPO_FROM_COMMENT/$REPO
|
||||
echo "Using docker_repo from issue comment: $DOCKER_REPO"
|
||||
else
|
||||
DOCKER_REPO=${{ vars.docker_repo2_registry }}/$REPO
|
||||
echo "Using fallback docker_repo: $DOCKER_REPO"
|
||||
fi
|
||||
|
||||
echo "TAG=$TAG" >> "$GITHUB_OUTPUT";
|
||||
echo "REPO=$REPO" >> "$GITHUB_OUTPUT";
|
||||
echo "SENDER=$SENDER" >> "$GITHUB_OUTPUT";
|
||||
echo "DOCKER_REPO=$DOCKER_REPO" >> "$GITHUB_OUTPUT";
|
||||
|
||||
- name: Print IMAGE and TAG
|
||||
run: |
|
||||
echo "BUILD_ID: ${{ steps.read-issue.outputs.BUILD_ID }}";
|
||||
echo "DOCKER_BASE: ${{ steps.read-issue.outputs.DOCKER_BASE }}";
|
||||
echo "TAG: ${{ steps.read-issue.outputs.TAG }}";
|
||||
echo "REPO: ${{ steps.read-issue.outputs.REPO }}";
|
||||
echo "SENDER: ${{ steps.read-issue.outputs.SENDER }}";
|
||||
echo "DOCKER_REPO: ${{ steps.read-issue.outputs.DOCKER_REPO }}";
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout cs repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.bot_build_repo_token }} #This is because we want to trigger a new build
|
||||
path: cs
|
||||
#Temporary problem git#v2.48.0 - tags aren't fetched with --tags. https://github.com/actions/checkout/issues/2041
|
||||
#fetch-depth: 50 #To get the topmost git tags
|
||||
#fetch-tags: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout deploy-tools
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: ${{ github.server_url }}
|
||||
repository: gmetribin/deploy-tools
|
||||
ref: main
|
||||
ref: v1.1.42
|
||||
path: deploy-tools
|
||||
token: ${{ github.token }}
|
||||
# token: $\{{ github.token }} # DEFAULT / Any pushes with github.token don't trigger a chained build
|
||||
|
||||
#To fetch tags correctly: https://github.com/actions/checkout/issues/1471#issuecomment-1755560284
|
||||
- name: Increment package version and push
|
||||
env:
|
||||
# GITHUB_TOKEN: ${{ secrets.PAT }} #This is because we want to trigger a new build
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
git config --global user.name 'bot-build'
|
||||
git config --global user.email 'techbots+build@gmetri.com'
|
||||
|
||||
BUILD_ID=${{ steps.read-issue.outputs.BUILD_ID }}
|
||||
DOCKER_BASE=${{ steps.read-issue.outputs.DOCKER_BASE }}
|
||||
TAG=${{ steps.read-issue.outputs.TAG }}
|
||||
export REPO=${{ steps.read-issue.outputs.REPO }}
|
||||
export SENDER=${{ steps.read-issue.outputs.SENDER }}
|
||||
DOCKER_REPO=${{ steps.read-issue.outputs.DOCKER_REPO }}
|
||||
REPOLIST=./.github/repolist.txt
|
||||
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_REPO -t $TAG -r $REPOLIST;
|
||||
|
||||
git push origin main
|
||||
git push --tags origin main
|
||||
git push origin main;
|
||||
git push --tags origin main;
|
||||
|
||||
37
.github/workflows/cs-update-trigger.yml
vendored
37
.github/workflows/cs-update-trigger.yml
vendored
@ -9,9 +9,10 @@ on:
|
||||
description: 'The cs repo that contains this image'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
REPO: ${{ github.repository }}
|
||||
docker_repo:
|
||||
description: 'The name of the action variable containing the docker repo value'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
trigger-cs-job:
|
||||
@ -24,33 +25,35 @@ 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_IMAGE=$DOCKER_BASE:$BUILD_ID;
|
||||
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||
echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT";
|
||||
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT";
|
||||
REPO=${{ github.repository }};
|
||||
echo "REPO=$REPO" >> "$GITHUB_OUTPUT";
|
||||
echo "TAG=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||
|
||||
- name: Print build id and image name
|
||||
- name: Print repo and tag
|
||||
run: |
|
||||
echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}";
|
||||
echo "DOCKER_BASE: ${{ steps.get-id.outputs.DOCKER_BASE }}";
|
||||
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||
echo "REPO: ${{ steps.get-id.outputs.REPO }}";
|
||||
echo "TAG: ${{ steps.get-id.outputs.TAG }}";
|
||||
|
||||
- name: Push image name and tag to cs repo's issue#1
|
||||
- name: Push image name and tag to cs repo's latest issue with label workflow
|
||||
run: |
|
||||
ISSUE_COMMENT_STRING=`echo "{ \"image\": \"${{ steps.get-id.outputs.DOCKER_BASE }}\", \"tag\": \"${{ steps.get-id.outputs.BUILD_ID }}\" }" | jq tostring`
|
||||
DOCKER_REPO_VALUE="${{ vars[inputs.docker_repo] }}"
|
||||
ISSUE_COMMENT_STRING=`echo "{ \"docker_repo\": \"$DOCKER_REPO_VALUE\", \"repo\": \"${{ steps.get-id.outputs.REPO }}\", \"tag\": \"${{ steps.get-id.outputs.TAG }}\", \"sender\": \"${{ github.event.sender.login }}\" }" | jq tostring`
|
||||
echo ISSUE_COMMENT_STRING: $ISSUE_COMMENT_STRING
|
||||
|
||||
API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring`
|
||||
echo API_JSON_BODY: $API_JSON_BODY
|
||||
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
|
||||
|
||||
set +x
|
||||
set -x
|
||||
ISSUE_JSON=`curl -X 'GET' \
|
||||
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues?labels=workflow&page=1&limit=1' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token ${{ secrets.bot_build_issues_token }}'`
|
||||
ISSUE_NUMBER=`echo $ISSUE_JSON | jq '.[0].number'`
|
||||
curl -X 'POST' \
|
||||
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/1/comments' \
|
||||
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/'$ISSUE_NUMBER'/comments' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Authorization: token ${{ secrets.bot_build_issues_token }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d $API_JSON_BODY
|
||||
set +x
|
||||
|
||||
|
||||
82
.github/workflows/nm-update.yml
vendored
Normal file
82
.github/workflows/nm-update.yml
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
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.42
|
||||
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;
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -129,4 +129,4 @@ dist
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
.idea/
|
||||
|
||||
@ -4,24 +4,20 @@
|
||||
### Functions
|
||||
usage()
|
||||
{
|
||||
echo "usage: $0 [-n nm-repo -c cs-repo -v version] | [-h]"
|
||||
echo "usage: $0 [-c cs-repo -v version -k kustomization_list] | [-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
|
||||
local CSLIST_PATH=$3 #"./.github/cslist.txt"
|
||||
|
||||
#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=$(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" ]
|
||||
@ -38,23 +34,20 @@ main()
|
||||
sed -i -e "s/${SEARCH_STRING}.*/${SEARCH_STRING}${VERSION}/" $KUST_PATH
|
||||
git add $KUST_PATH
|
||||
done <<< "$CSLIST"
|
||||
|
||||
git commit -m "$NM_REPO_NAME updated with $CS_REPO_NAME: $VERSION"
|
||||
git push origin master
|
||||
}
|
||||
|
||||
### Starts here
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-n | --nm-repo ) shift
|
||||
NM_REPO_NAME=$1
|
||||
;;
|
||||
-c | --cs-repo ) shift
|
||||
CS_REPO_NAME=$1
|
||||
;;
|
||||
-v | --version ) shift
|
||||
VERSION=$1
|
||||
;;
|
||||
-k | --kustomization_list ) shift
|
||||
CSLIST_PATH=$1
|
||||
;;
|
||||
-h | --help ) usage
|
||||
exit
|
||||
;;
|
||||
@ -64,11 +57,11 @@ while [ "$1" != "" ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $NM_REPO_NAME || -z $CS_REPO_NAME || -z $VERSION ]]
|
||||
if [[ -z $CS_REPO_NAME || -z $VERSION || -z $CSLIST_PATH ]]
|
||||
then
|
||||
echo "Not enough arguments"
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
main "$NM_REPO_NAME" "$CS_REPO_NAME" "$VERSION"
|
||||
main "$CS_REPO_NAME" "$VERSION" "$CSLIST_PATH"
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||
echo "Script directory: $SCRIPT_DIR"
|
||||
|
||||
### Functions
|
||||
usage()
|
||||
@ -9,7 +11,7 @@ usage()
|
||||
main()
|
||||
{
|
||||
local IMAGE=$1
|
||||
local TAG=$2
|
||||
local IMAGE_TAG=$2
|
||||
local REPOLIST=$3
|
||||
|
||||
KUST_FILES_LINES=$(grep -e "$IMAGE\s" $REPOLIST)
|
||||
@ -29,22 +31,20 @@ main()
|
||||
#Replace repo verion in kustomization.yaml. -n is true only if the following argument is non empty
|
||||
if [ -n "$LINE_N2" ]
|
||||
then
|
||||
echo "Replacement Op: sed -i -e \"${LINE_N2}s/newTag: .*/newTag: ${TAG}/\" \"$KUST_PATH\""
|
||||
sed -i -e "${LINE_N2}s/newTag: .*/newTag: ${TAG}/" "$KUST_PATH"
|
||||
echo "Replacement Op: sed -i -e \"${LINE_N2}s/newTag: .*/newTag: ${IMAGE_TAG}/\" \"$KUST_PATH\""
|
||||
sed -i -e "${LINE_N2}s/newTag: .*/newTag: ${IMAGE_TAG}/" "$KUST_PATH"
|
||||
|
||||
git add $KUST_PATH;
|
||||
fi
|
||||
done <<< "$KUST_FILES_LINES"
|
||||
|
||||
VER=$(cat version)
|
||||
NEW_VER=$(./drone/increment_semver.sh -p $VER)
|
||||
echo "$NEW_VER" > version
|
||||
CS_REPO_NAME=`node -p require\(\'./package.json\'\).name`
|
||||
source $SCRIPT_DIR/repo_to_cs_basetag.sh;
|
||||
|
||||
git add version
|
||||
git commit -m "$NEW_VER: $IMAGE updated to $TAG [CI SKIP]"
|
||||
git tag -a $NEW_VER -m "$NEW_VER: $IMAGE updated to $TAG [CI SKIP]"
|
||||
echo "NEW_TAG: $NEW_TAG"
|
||||
COMMIT_MESSAGE="$NEW_TAG: $REPO to $IMAGE_TAG by $SENDER";
|
||||
|
||||
git commit -m "$COMMIT_MESSAGE"
|
||||
git tag -a $NEW_TAG -m "$COMMIT_MESSAGE"
|
||||
}
|
||||
|
||||
### Starts here
|
||||
@ -54,7 +54,7 @@ while [ "$1" != "" ]; do
|
||||
IMAGE=$1
|
||||
;;
|
||||
-t | --tag ) shift
|
||||
TAG=$1
|
||||
IMAGE_TAG=$1
|
||||
;;
|
||||
-r | --repolist ) shift
|
||||
REPOLIST=$1
|
||||
@ -68,11 +68,11 @@ while [ "$1" != "" ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $IMAGE || -z $TAG || -z $REPOLIST ]]
|
||||
if [[ -z $IMAGE || -z $IMAGE_TAG || -z $REPOLIST ]]
|
||||
then
|
||||
echo "Not enough arguments"
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
main "$IMAGE" "$TAG" "$REPOLIST"
|
||||
main "$IMAGE" "$IMAGE_TAG" "$REPOLIST"
|
||||
|
||||
63
src/repo_to_cs_basetag.sh
Executable file
63
src/repo_to_cs_basetag.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# #For a fresh repo / Creating new releases
|
||||
# git add -A;
|
||||
# git commit -m "<commit msg>"
|
||||
# #Setting a tag
|
||||
# git tag -a -m "<tag msg>" v1.0.0
|
||||
# git push --follow-tags
|
||||
# #Moving a tag (eg: for major version retagging)
|
||||
# git tag -fa v1
|
||||
# git push --tags -f
|
||||
|
||||
# Based on https://gist.github.com/CSTDev/08c127680e3b5fae38c051da3e489351
|
||||
# Commit with a log containing #minor or #major to increment the respective version number
|
||||
|
||||
#get highest tag number containing at least 2 dots
|
||||
VERSION=`git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*"`
|
||||
|
||||
#replace . with space so can split into an array
|
||||
VERSION_BITS=(${VERSION//./ })
|
||||
|
||||
#get number parts and increase last one by 1
|
||||
VNUM1=${VERSION_BITS[0]}
|
||||
VNUM2=${VERSION_BITS[1]}
|
||||
VNUM3=${VERSION_BITS[2]}
|
||||
VNUM1=`echo $VNUM1 | sed 's/v//'`
|
||||
|
||||
# Check for #major or #minor in commit message and increment the relevant version number
|
||||
MAJOR=`git log --format=%B -n 1 HEAD | grep '#major'`
|
||||
MINOR=`git log --format=%B -n 1 HEAD | grep '#minor'`
|
||||
|
||||
if [ "$MAJOR" ]; then
|
||||
echo "Update major version"
|
||||
VNUM1=$((VNUM1+1))
|
||||
VNUM2=0
|
||||
VNUM3=0
|
||||
elif [ "$MINOR" ]; then
|
||||
echo "Update minor version"
|
||||
VNUM2=$((VNUM2+1))
|
||||
VNUM3=0
|
||||
else
|
||||
echo "Update patch version"
|
||||
VNUM3=$((VNUM3+1))
|
||||
fi
|
||||
|
||||
|
||||
#create new tag
|
||||
NEW_TAG="v$VNUM1.$VNUM2.$VNUM3"
|
||||
|
||||
# echo "Updating $VERSION to $NEW_TAG"
|
||||
|
||||
# #get current hash and see if it already has a tag
|
||||
# GIT_COMMIT=`git rev-parse HEAD`
|
||||
# NEEDS_TAG=`git describe --contains $GIT_COMMIT`
|
||||
|
||||
# #only tag if no tag already (would be better if the git describe command above could have a silent option)
|
||||
# if [ -z "$NEEDS_TAG" ]; then
|
||||
# echo "Tagged with $NEW_TAG (Ignoring fatal:cannot describe - this means commit is untagged) "
|
||||
# git tag $NEW_TAG
|
||||
# git push --tags
|
||||
# else
|
||||
# echo "Already a tag on this commit"
|
||||
# fi
|
||||
Loading…
x
Reference in New Issue
Block a user