diff --git a/.github/workflows/generate-readme.yml b/.github/workflows/generate-readme.yml index 5bba7f6b..7005ba47 100644 --- a/.github/workflows/generate-readme.yml +++ b/.github/workflows/generate-readme.yml @@ -11,7 +11,11 @@ on: - main paths: - 'README.template.md' - workflow_dispatch: # Allows manual execution + workflow_dispatch: # Allows for manual execution + workflow_run: # Triggers this workflow to run when it recognizes 'publish-images' workflow has ran and successfully completed + workflows: ["Publish Docker Image to Registries"] + types: + - completed permissions: contents: write # Explicitly allow pushing changes @@ -41,28 +45,32 @@ jobs: - name: Install Dependencies run: npm install mustache dotenv - - name: Download Version File - uses: actions/download-artifact@v4.1.8 - with: - name: version-metadata - - - name: Load Variables from File + - name: Extract Major and Major-Minor Versions run: | - while IFS='=' read -r key value; do - echo "$key=$value" >> $GITHUB_ENV - done < versions.txt + VERSION="${{ vars.BUILD_VERSION }}" + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2) + + echo "Full version: $VERSION" + echo "Major version: $MAJOR" + echo "Major-Minor version: $MAJOR_MINOR" + + # Export all as environment variables + echo "LATEST_VERSION=$VERSION" >> $GITHUB_ENV + echo "LATEST_MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV + echo "LATEST_MAJOR_MINOR_VERSION=$MAJOR_MINOR" >> $GITHUB_ENV - name: Generate README.md env: - BUILD_FULL_VERSION: ${{ env.BUILD_FULL_VERSION }} # e.g., 1.2.3 - BUILD_MAJOR_MINOR_VERSION: ${{ env.BUILD_MAJOR_MINOR_VERSION }} # e.g., 1.2 - BUILD_MAJOR_VERSION: ${{ env.BUILD_MAJOR_VERSION }} # e.g., 1 + BUILD_FULL_VERSION: ${{ env.LATEST_VERSION }} # e.g., 1.2.3 + BUILD_MAJOR_VERSION: ${{ env.LATEST_MAJOR_VERSION}} # e.g., 1 + BUILD_MAJOR_MINOR_VERSION: ${{ env.LATEST_MAJOR_MINOR_VERSION }} # e.g., 1.2 run: node scripts/generate-readme.js - name: Commit and Push Changes env: - KENER_GH_PAT_TOKEN: ${{ secrets.KENER_GH_PAT_TOKEN }} + GH_PAT: ${{ secrets.GH_PAT }} 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 + git push https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git HEAD:main