mirror of
https://github.com/rajnandan1/kener.git
synced 2026-05-05 01:59:33 -05:00
f70e2ee8eb
Changes include: * Moving README generation to separate workflow (so that it can be trigger to run when any changes to `README.template.md` are pushed to `main` branch or a PR is opened with changes to template file * GitHub Actions do not have privileges via `GITHUB_TOKEN` to commit to protected branches, thus, we need to take another approach and utilize a personal access token (which you’ll need to generate @rajnandan1) and add to the repository secrets (to avoid exposing that credential). * Changes `publish-images` workflow to run now only when a new GitHub Release is created. (This will help prevent excessive workflow runs on merges into `main`)…in other words, @rajnandan1, you can merge freely into `main` now without excessive GitHub Actions usage.
69 lines
2.0 KiB
YAML
69 lines
2.0 KiB
YAML
name: Generate README
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'README.template.md'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'README.template.md'
|
|
workflow_dispatch: # Allows manual execution
|
|
|
|
permissions:
|
|
contents: write # Explicitly allow pushing changes
|
|
|
|
jobs:
|
|
generate-readme:
|
|
name: Generate README from template
|
|
runs-on: ubuntu-latest
|
|
# permissions:
|
|
# contents: write # Explicitly allow pushing changes
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4.2.2
|
|
with:
|
|
persist-credentials: false # We'll manually authenticate
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config --global user.name "github-actions"
|
|
git config --global user.email "github-actions@github.com"
|
|
|
|
- name: Extract Release Versions
|
|
id: meta
|
|
uses: docker/metadata-action@v5.6.1
|
|
with:
|
|
images: rajnandan1/kener
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4.2.0
|
|
with:
|
|
node-version: "20"
|
|
|
|
- name: Install Dependencies
|
|
run: npm install mustache dotenv
|
|
|
|
- name: Generate README.md
|
|
env:
|
|
KENER_BUILD_FULL_VERSION: ${{ steps.meta.outputs.tags[0] }} # e.g., 1.2.3
|
|
KENER_BUILD_MAJOR_MINOR_VERSION: ${{ steps.meta.outputs.tags[1] }} # e.g., 1.2
|
|
KENER_BUILD_MAJOR_VERSION: ${{ steps.meta.outputs.tags[2] }} # e.g., 1
|
|
run: node scripts/generate-readme.js
|
|
|
|
- name: Commit and Push Changes
|
|
env:
|
|
KENER_GH_PAT_TOKEN: ${{ secrets.KENER_GH_PAT_TOKEN }}
|
|
run: |
|
|
git add README.md
|
|
git commit -m "Auto-generate README.md with release versions" || echo "No changes to commit"
|
|
git push https://x-access-token:${{ secrets.KENER_GH_PAT_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main
|