Skip to content

Apps/nutritionfacts/invalidhooks (#192) #103

Apps/nutritionfacts/invalidhooks (#192)

Apps/nutritionfacts/invalidhooks (#192) #103

Workflow file for this run

name: Tag on Merge
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
retag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Retag all changed packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BEFORE_SHA="${{ github.event.before }}"
AFTER_SHA="${{ github.sha }}"
# Try diffing with BEFORE_SHA, fallback to HEAD~1 if not available
if git cat-file -e "$BEFORE_SHA" 2>/dev/null; then
DIFF_RANGE="$BEFORE_SHA $AFTER_SHA"
else
DIFF_RANGE="HEAD~1 HEAD"
fi
for pkgjson in $(git diff --name-only $DIFF_RANGE | grep -E '^(package.json|packages/.*/package.json|apps/.*/package.json)$'); do
NAME=$(jq -r .name $pkgjson)
VERSION=$(jq -r .version $pkgjson)
TAG="${NAME}@${VERSION}"
# Check if tag exists remotely
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
echo "Tag $TAG already exists on remote, skipping push."
else
git tag $TAG
git push origin $TAG
fi
done