snapshot #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A temporary workflow to create a snapshot tag for the current commit | |
# | |
# This workflow is triggered by a cron job that runs once every hour. | |
# | |
# TODO(azjezz): Remove this workflow once the snapshot tag is no longer needed, | |
# i.e. when we have a release tag > 0.0.0. | |
name: snapshot | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" # runs once every hour, at the top of the hour | |
jobs: | |
create_snapshot: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout main | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: get latest commit short hash | |
id: commit | |
run: | | |
SHORT_HASH=$(git rev-parse --short HEAD) | |
echo "SHORT_HASH=${SHORT_HASH}" >> $GITHUB_OUTPUT | |
- name: check if tag exists | |
id: check_tag | |
run: | | |
TAG_NAME="0.0.0-${{ steps.commit.outputs.SHORT_HASH }}" | |
# Check if this tag already exists | |
if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then | |
echo "exists=true" >> $GITHUB_OUTPUT | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT | |
fi | |
- name: create and push tag | |
if: steps.check_tag.outputs.exists == 'false' | |
run: | | |
TAG_NAME="0.0.0-${{ steps.commit.outputs.SHORT_HASH }}" | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git tag $TAG_NAME | |
git push origin $TAG_NAME |