Skip to content

Update projectData.ts #2

Update projectData.ts

Update projectData.ts #2

name: Auto Update Version and Build
on:
push:
branches:
- master
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
update-version-and-build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
# Skip if the commit message contains the auto-increment marker to prevent infinite loops
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Update version using Node.js script
id: version_update
run: |
# Make script executable
chmod +x .github/scripts/increment-version.js
# Run the version increment script
node .github/scripts/increment-version.js
# Display updated file
echo "Updated projectData.ts:"
cat apps/web/projectData.ts
- name: Check for changes
id: git_status
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit version changes
if: steps.git_status.outputs.changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add apps/web/projectData.ts
git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new }}"
git push
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ steps.version_update.outputs.new }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,prefix=
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Output summary
run: |
echo "## Version Update Summary" >> $GITHUB_STEP_SUMMARY
echo "- Previous version: ${{ steps.version_update.outputs.current }}" >> $GITHUB_STEP_SUMMARY
echo "- New version: ${{ steps.version_update.outputs.new }}" >> $GITHUB_STEP_SUMMARY
echo "- Docker image built with tags:" >> $GITHUB_STEP_SUMMARY
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new }}" >> $GITHUB_STEP_SUMMARY