Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CD

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v5
- uses: softprops/action-gh-release@v2
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
- push

Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI workflow does not set 'contents: write' permission, which is required for the action to push tags to the repository. Without this permission, the git push command in the action will fail. Add a 'permissions' section with 'contents: write' to this workflow, similar to what's done in the CD workflow.

Suggested change
permissions:
contents: write

Copilot uses AI. Check for mistakes.
jobs:
tests:
name: Tests
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v5
- id: create-datetime-tag
uses: ./
- run: |
TAG="${{ steps.create-datetime-tag.outputs.tag }}"
echo "Tag created: $TAG"

if [ -z "$TAG" ]; then
echo "❌ Error: Tag output is empty"
exit 1
fi

# Verify tag exists locally
if ! git tag -l | grep -q "^$TAG$"; then
echo "❌ Error: Tag $TAG not found locally"
exit 1
fi
echo "✅ Tag exists locally"

# Verify tag was pushed to remote
if ! git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
echo "❌ Error: Tag $TAG not found on remote"
exit 1
fi
echo "✅ Tag exists on remote"

echo "✅ All tests passed!"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# create-datetime-tag
# @actalog/create-datetime-tag

Creates and pushes a git tag based on the current date and time.
27 changes: 27 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: '@actalog/create-datetime-tag'
author: Gabriel Rufino <contato@gabrielrufino.com>
description: 'Creates and pushes a git tag based on the current date and time.'
branding:
icon: tag
color: orange

outputs:
tag:
description: 'The created tag name'
value: ${{ steps.create-tag.outputs.tag }}

runs:
using: composite
steps:
- id: create-tag
shell: bash
run: |
TAG=$(date +%Y-%m-%d.%H-%M)

echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Creating tag: $TAG"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Auto-generated tag for $TAG"
git push origin "$TAG"
Comment on lines +25 to +26
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action will fail if it doesn't have permissions to push to the repository. The composite action runs in the context of the calling workflow, which means the workflow needs to grant 'contents: write' permission. Consider adding a note in the action description or README about this requirement, or add error handling to provide a clearer message when the push fails due to insufficient permissions.

Copilot uses AI. Check for mistakes.
echo "Tag $TAG created and pushed successfully!"
Comment on lines +25 to +27
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action does not handle the case where a tag with the same name already exists. If the action runs twice within the same minute, the 'git tag' command will fail because the tag already exists. Consider adding error handling or checking if the tag exists before creating it, or appending seconds to the timestamp to reduce collision likelihood.

Suggested change
git tag -a "$TAG" -m "Auto-generated tag for $TAG"
git push origin "$TAG"
echo "Tag $TAG created and pushed successfully!"
if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then
echo "Tag $TAG already exists. Skipping creation and push."
else
git tag -a "$TAG" -m "Auto-generated tag for $TAG"
git push origin "$TAG"
echo "Tag $TAG created and pushed successfully!"
fi

Copilot uses AI. Check for mistakes.