From 8912f3b4a6f37362710d61f148ec091c4a437083 Mon Sep 17 00:00:00 2001 From: Mateusz Urbanek Date: Sat, 13 Jan 2024 20:21:51 +0100 Subject: [PATCH] fix(cli): compatibility with v3alpha7 code (#14) Signed-off-by: Mateusz Urbanek --- .github/labels.yaml | 42 +++++++++++++-------------- .github/workflows/example.yaml | 20 ++++--------- .github/workflows/release-please.yaml | 1 + cmd/labeler/download/download.go | 10 +++---- cmd/labeler/upload/upload.go | 10 +++---- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/.github/labels.yaml b/.github/labels.yaml index 58db20b..2daa633 100644 --- a/.github/labels.yaml +++ b/.github/labels.yaml @@ -1,63 +1,63 @@ - name: api - color: 6f42c1 + color: '#6f42c1' description: Issues related to the GitHub API - name: enhancement - color: 0dd8ac + color: '#0dd8ac' description: New feature or improvement request - name: high-priority - color: ff7b72 + color: '#ff7b72' description: Issue with high priority - name: dependency - color: dadada + color: '#dadada' description: Dependency updates - name: question - color: ffb000 + color: '#ffb000' description: Questions or need for further clarification - name: test - color: ffffff + color: '#ffffff' description: "Test label. \U0001F6A7" - name: invalid - color: e4e669 + color: '#e4e669' description: Issue is no longer valid or applicable - name: duplicate - color: cfd3d7 + color: '#cfd3d7' description: Issue already reported or duplicated - name: feature-request - color: 61dafb + color: '#61dafb' description: Request for a new feature or enhancement - name: feedback - color: d4c5f9 + color: '#d4c5f9' description: Feedback or suggestions for improvement - name: help-wanted - color: 7057ff + color: '#7057ff' description: Contribution opportunities available - name: in-progress - color: 2a8b9d + color: '#2a8b9d' description: Issue currently being worked on - name: testing - color: 36bcef + color: '#36bcef' description: Issues related to testing or test cases - name: ¯\_(ツ)_/¯ - color: f9d0c4 + color: '#f9d0c4' description: ¯\\\_(ツ)_/¯ - name: critical - color: e00808 + color: '#e00808' description: Critical issue that requires immediate attention - name: documentation - color: 007bc7 + color: '#007bc7' description: Issues related to documentation - name: hacktoberfest - color: ff6b00 + color: '#ff6b00' description: Issues related to the Hacktoberfest event - name: resolved - color: 28a745 + color: '#28a745' description: Issue has been resolved - name: bug - color: d73a4a + color: '#d73a4a' description: Something isn't working as expected - name: low-priority - color: 8c8c8c + color: '#8c8c8c' description: Issue with low priority - name: wontfix - color: a2eeef + color: '#a2eeef' description: Issue won't be fixed or addressed diff --git a/.github/workflows/example.yaml b/.github/workflows/example.yaml index 65af4f1..431859b 100644 --- a/.github/workflows/example.yaml +++ b/.github/workflows/example.yaml @@ -7,21 +7,13 @@ on: paths: - .github/labels.yml -permissions: write-all - -env: - OWNER: shanduur - REPO: ${{ github.event.repository.name }} - jobs: upload-labels: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - run: go install github.com/shanduur/labeler/cmd/labeler@main - - run: labeler upload --owner ${{ env.OWNER }} --repo ${{ env.REPO }} ./.github/labels.yaml - env: - LABELER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v3 + - uses: shanduur/declarative-labels-sync-action@main + with: + owner: shanduur + repository: ${{ github.event.repository.name }} + token: ${{ secrets.PAT }} diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 784c3d3..bcb064b 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -16,3 +16,4 @@ jobs: - uses: google-github-actions/release-please-action@v3 with: release-type: go + token: ${{ secrets.PAT }} diff --git a/cmd/labeler/download/download.go b/cmd/labeler/download/download.go index 556c203..8877389 100644 --- a/cmd/labeler/download/download.go +++ b/cmd/labeler/download/download.go @@ -32,18 +32,18 @@ func New() *cli.Command { Flags: []cli.Flag{ flagOutput, }, - Action: func(ctx *cli.Context) error { - if ctx.Args().Len() == 0 { + Action: func(ctx context.Context, cmd *cli.Command) error { + if cmd.Args().Len() == 0 { return errors.New("nothing to do") } client := github.NewClient(nil) - for i := 0; i < ctx.NArg(); i++ { - ghPath := ctx.Args().Get(i) + for i := 0; i < cmd.NArg(); i++ { + ghPath := cmd.Args().Get(i) owner, repo := getOwnerRepo(ghPath) - l, err := listAll(ctx.Context, client, owner, repo) + l, err := listAll(ctx, client, owner, repo) if err != nil { return fmt.Errorf("unable to list all: %w", err) } diff --git a/cmd/labeler/upload/upload.go b/cmd/labeler/upload/upload.go index a14aecb..68b14a2 100644 --- a/cmd/labeler/upload/upload.go +++ b/cmd/labeler/upload/upload.go @@ -40,8 +40,8 @@ func New() *cli.Command { flagOwner, flagRepo, }, - Action: func(ctx *cli.Context) error { - if ctx.Args().Len() != 1 { + Action: func(ctx context.Context, cmd *cli.Command) error { + if cmd.Args().Len() != 1 { return errors.New("wrong number of arguments, expected single ") } @@ -54,11 +54,11 @@ func New() *cli.Command { &oauth2.Token{AccessToken: token}, ) - tc := oauth2.NewClient(ctx.Context, ts) + tc := oauth2.NewClient(ctx, ts) client := github.NewClient(tc) - f, err := os.Open(ctx.Args().First()) + f, err := os.Open(cmd.Args().First()) if err != nil { return fmt.Errorf("unable to open file: %w", err) } @@ -73,7 +73,7 @@ func New() *cli.Command { for _, label := range lbls { slog.Info("processing label", "label_name", label.Name, "label.color", label.Color) - err = uploadLabel(ctx.Context, client, owner, repo, label) + err = uploadLabel(ctx, client, owner, repo, label) if err != nil { return fmt.Errorf("unable to update label: %w", err) }