feat: add building old patch from custom branch
Option to input tag and branch to avoid local git gymnstics Ensures the workflow fails appropriately when git pull --rebase fails instead of silently continuing execution. This prevents downstream build errors and makes troubleshooting easier when the rebase fails. Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
parent
7cfef90cc8
commit
0d221914c0
1 changed files with 18 additions and 10 deletions
28
.github/workflows/patch-build-old.yaml
vendored
28
.github/workflows/patch-build-old.yaml
vendored
|
|
@ -7,8 +7,12 @@ on:
|
|||
description: 'Comma separated names of services to build(in small letters).'
|
||||
required: true
|
||||
default: 'chalice,frontend'
|
||||
branch:
|
||||
description: 'branch to build patches from.'
|
||||
required: true
|
||||
type: string
|
||||
tag:
|
||||
description: 'Tag to build patches from.'
|
||||
description: 'Tag to update using the branch.'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
|
@ -26,7 +30,7 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 4
|
||||
ref: ${{ github.event.inputs.tag }}
|
||||
ref: ${{ github.event.inputs.branch }}
|
||||
|
||||
- name: Set Remote with GITHUB_TOKEN
|
||||
run: |
|
||||
|
|
@ -36,11 +40,14 @@ jobs:
|
|||
- name: Create backup tag with timestamp
|
||||
run: |
|
||||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
||||
BACKUP_TAG="${{ github.event.inputs.tag }}-backup-${TIMESTAMP}"
|
||||
echo "BACKUP_TAG=${BACKUP_TAG}" >> $GITHUB_ENV
|
||||
echo "INPUT_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
||||
git tag $BACKUP_TAG || { echo "Failed to create backup tag"; exit 1; }
|
||||
echo "INPUT_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
||||
|
||||
git tag $BACKUP_TAG $INPUT_TAG || { echo "Failed to create backup tag"; exit 1; }
|
||||
git push origin $BACKUP_TAG || { echo "Failed to push backup tag"; exit 1; }
|
||||
echo "Created backup tag: $BACKUP_TAG"
|
||||
|
||||
|
|
@ -51,6 +58,14 @@ jobs:
|
|||
NEW_TIMESTAMP=$((OLDEST_COMMIT_TIMESTAMP + 1))
|
||||
echo "NEW_TIMESTAMP=$NEW_TIMESTAMP" >> $GITHUB_ENV
|
||||
|
||||
echo "HEAD_COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: rebasing tag
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git fetch origin --tags -f
|
||||
git rebase $INPUT_TAG || { echo "Failed to pull and rebase from branch $INPUT_BRANCH with tag $INPUT_TAG"; exit 1; }
|
||||
|
||||
- name: Setup yq
|
||||
uses: mikefarah/yq@master
|
||||
|
|
@ -70,10 +85,6 @@ jobs:
|
|||
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.RELEASE_OSS_REGISTRY }}
|
||||
|
||||
- uses: depot/setup-action@v1
|
||||
- name: Get HEAD Commit ID
|
||||
run: echo "HEAD_COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
- name: Define Branch Name
|
||||
run: echo "BRANCH_NAME=patch/main/${HEAD_COMMIT_ID}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build
|
||||
id: build-image
|
||||
|
|
@ -85,9 +96,6 @@ jobs:
|
|||
MSAAS_REPO_FOLDER: /tmp/msaas
|
||||
run: |
|
||||
set -exo pipefail
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git checkout -b $BRANCH_NAME
|
||||
working_dir=$(pwd)
|
||||
function image_version(){
|
||||
local service=$1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue