Skip to content

chore: testing workflow #10

chore: testing workflow

chore: testing workflow #10

Workflow file for this run

name: Tagging Workflow
env:
TARGET_DIR: 'stuff' # Define the target directory here
on:
push:
branches:
- main
paths:
- 'stuff/**' # Use the target directory variable here
permissions: # Ensure the workflow has the necessary permissions to push tags
contents: write
jobs:
tag-on-change:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Get current date and time
id: datetime
run: echo "::set-output name=timestamp::$(date +'%Y%m%d%H%M%S')"
- name: Check for changes in subdirectories
id: check_changes
run: |
CHANGED_DIRS=""
for dir in ${{ env.TARGET_DIR }}/*; do # Use the target directory variable here
if ! git diff --quiet HEAD^ HEAD -- "$dir"; then
# If changes are detected, append the directory to the list
CHANGED_DIRS="$CHANGED_DIRS $dir"
fi
done
if [ -z "$CHANGED_DIRS" ]; then
echo "No changes detected in ${{ env.TARGET_DIR }}/* directories." # Use the target directory variable here
exit 0
else
# Output the changed directories for further steps
echo "Changed directories: $CHANGED_DIRS"
echo "::set-output name=changed_dirs::$CHANGED_DIRS"
fi
- name: Create and push tag
if: steps.check_changes.outputs.changed_dirs
run: |
for dir in ${{ steps.check_changes.outputs.changed_dirs }}; do
echo "Changed directory is $dir"
TAG_NAME="$dir-${{ steps.datetime.outputs.timestamp }}"
git config user.name github-actions
git config user.email github-actions@github.com
git tag $TAG_NAME
git push origin $TAG_NAME
echo "Tag $TAG_NAME created for $dir."
done