From 6b9cf79e61b43b145e39cc26174b3144892945ac Mon Sep 17 00:00:00 2001 From: Yidi Date: Sat, 5 Oct 2024 15:12:54 -0400 Subject: [PATCH] chore(workflow): enhance label sync with GitHub CLI setup This commit enhances the GitHub Actions workflow for syncing labels by setting up and installing the GitHub CLI. This allows for more robust label management, leveraging GitHub CLI commands for label creation and updates. The use of `GH_TOKEN` ensures secure authentication, improving the overall workflow security and efficiency. --- .github/workflows/sync-labels.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index a79bac4..bd27b9c 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -16,7 +16,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up GitHub CLI + uses: actions/setup-node@v4 + with: + node-version: '16' + + - name: Install GitHub CLI + run: sudo apt-get install -y gh + - name: Configure repository labels + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | echo "::group::Reading labels JSON file" labels=$(cat .github/labels.json) @@ -30,7 +40,5 @@ jobs: echo "Updating label: $name with color #$color and description '$description'" - # Update the labels using the create-or-update-label action gh label create "$name" --color "$color" --description "$description" || gh label edit "$name" --color "$color" --description "$description" - done