ci(actions): Auto update tag for patch build (#3387)
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
parent
f38b3a830d
commit
0c64003b09
1 changed files with 25 additions and 11 deletions
36
.github/workflows/update-tag.yaml
vendored
36
.github/workflows/update-tag.yaml
vendored
|
|
@ -1,35 +1,49 @@
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
description: "This workflow will build for patches for latest tag, and will Always use commit from main branch."
|
|
||||||
inputs:
|
inputs:
|
||||||
services:
|
services:
|
||||||
description: "This action will update the latest tag with current main branch HEAD. Should I proceed ? true/false"
|
description: "This action will update the latest tag with current main branch HEAD. Should I proceed ? true/false"
|
||||||
required: true
|
required: true
|
||||||
default: "false"
|
default: "false"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
name: Force Push tag with main branch HEAD
|
name: Release tag update --force
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Build Patch from main
|
name: Build Patch from main
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
if: ${{ github.event_name == 'push' || github.event.inputs.services == 'true' }}
|
||||||
DEPOT_TOKEN: ${{ secrets.DEPOT_TOKEN }}
|
|
||||||
DEPOT_PROJECT_ID: ${{ secrets.DEPOT_PROJECT_ID }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get latest release tag using GitHub API
|
||||||
|
id: get-latest-tag
|
||||||
|
run: |
|
||||||
|
LATEST_TAG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases/latest" \
|
||||||
|
| jq -r .tag_name)
|
||||||
|
|
||||||
|
# Fallback to git command if API doesn't return a tag
|
||||||
|
if [ "$LATEST_TAG" == "null" ] || [ -z "$LATEST_TAG" ]; then
|
||||||
|
echo "Not found latest tag"
|
||||||
|
exit 100
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
||||||
|
echo "Latest tag: $LATEST_TAG"
|
||||||
|
|
||||||
- name: Set Remote with GITHUB_TOKEN
|
- name: Set Remote with GITHUB_TOKEN
|
||||||
run: |
|
run: |
|
||||||
git config --unset http.https://github.com/.extraheader
|
git config --unset http.https://github.com/.extraheader
|
||||||
git remote set-url origin https://x-access-token:${{ secrets.ACTIONS_COMMMIT_TOKEN }}@github.com/${{ github.repository }}.git
|
git remote set-url origin https://x-access-token:${{ secrets.ACTIONS_COMMMIT_TOKEN }}@github.com/${{ github.repository }}.git
|
||||||
|
|
||||||
- name: Push main branch to tag
|
- name: Push main branch to tag
|
||||||
run: |
|
run: |
|
||||||
git fetch --tags
|
git fetch --tags
|
||||||
git checkout main
|
git checkout main
|
||||||
git push origin HEAD:refs/tags/$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1) --force
|
echo "Updating tag ${{ env.LATEST_TAG }} to point to latest commit on main"
|
||||||
# - name: Debug Job
|
git push origin HEAD:refs/tags/${{ env.LATEST_TAG }} --force
|
||||||
# if: ${{ failure() }}
|
|
||||||
# uses: mxschmitt/action-tmate@v3
|
|
||||||
# with:
|
|
||||||
# limit-access-to-actor: true
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue