Skip to content

Instantly share code, notes, and snippets.

@Soecka
Last active November 8, 2024 13:40
Show Gist options
  • Save Soecka/82f16978f39228e1ef852f30bd48a855 to your computer and use it in GitHub Desktop.
Save Soecka/82f16978f39228e1ef852f30bd48a855 to your computer and use it in GitHub Desktop.
Update repository about fields with github action
name: CI & CD
on:
push:
branches:
- main
paths:
- package.json
jobs:
Build-and-Publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
env:
HOME_PAGE: ${{github.repositoryUrl}}
TOPICS: idea2app,agile,devops,cloud,it-transformation,efficient,github,open-source,automation
DESCRIPTION: Industry-wide IT transformation expert
- name: get content
run: |
DESCRIPTION=$(node -p "JSON.parse(require('fs').readFileSync('package.json')).description || ''")
HOME_PAGE=$(node -p "JSON.parse(require('fs').readFileSync('package.json')).homepage || ''")
TOPICS=$(node -p "JSON.parse(require('fs').readFileSync('package.json')).keywords?.join(',').toLowerCase() || ''")
[[ "$DESCRIPTION" ]] && gh repo edit "$REPOSITORY" --description "$DESCRIPTION"
[[ "$HOME_PAGE" ]] && gh repo edit "$REPOSITORY" --homepage "$HOME_PAGE"
[[ "$TOPICS" ]] && {
gh api --method PUT "repos/$REPOSITORY/topics" -f "names[]"
gh repo edit "$REPOSITORY" --add-topic "$TOPICS"
}
env:
# "Administration" repository permissions (write), https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#replace-all-repository-topics
GH_TOKEN: ${{ secrets.ADMIN_TOKEN }}
REPOSITORY: ${{ github.repository }}
@Soecka
Copy link
Author

Soecka commented Oct 30, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment