feat: Expose gitops-pusher result as step outputs (e.g. for PR comments)

オープン
#84 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
github-actions, shell, yaml
領域
ci-cd, devops, tooling

調査の方向性

Start in action.yml, especially the Gitops pusher step and the action's existing outputs and execution flow. Exercise the action: test path with a successful and failing policy check, then verify the declared outcome, output, and changed values are available to later steps while failures still produce a non-zero status.

索引モデルが issue の本文から書いたものです。

説明

Summary

Expose the result of gitops-pusher as step outputs so a later step in the workflow can report it, for example by posting a comment on the pull request.

Motivation

When action: test runs on a pull request, the only place to see why it failed is the job log. For example:

test(s) failed

For user tag:example:
Errors found:
- [acl test error]: address "tag:server:22" (protocol "tcp"): want: Drop, got: Accept

exit status 1

It would be much easier to review policy changes if that message could be posted to the PR automatically. Right now the action gives a later step nothing to work with:

  • It defines no outputs, so later steps can't read the result or the error text.
  • The output from gitops-pusher only goes to the job log.

To get a PR comment today, I had to stop using the action for PR checks and copy what it does into my own workflow: set up Go, pin the same gitops-pusher commit, run it with | tee, and fetch the live policy from the API myself. I'd rather keep using the action and keep getting its updates.

Proposed change

Add outputs to the action, for example:

Output Description
outcome success or failure from gitops-pusher
output Everything gitops-pusher printed (stdout and stderr), or at least the error part
changed true if the local policy differs from the live policy (control vs. local ETag)

A diff between the live policy and the local file would also be helpful as an output, so reviewers can see exactly what merging will change. If that doesn't fit this action, the three outputs above cover the main need.

With these outputs, a workflow could do this:

- name: Test ACL
  id: test-acl
  uses: tailscale/gitops-acl-action@v1
  continue-on-error: true
  with:
    oauth-client-id: ${{ secrets.TS_OAUTH_ID }}
    oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
    tailnet: ${{ secrets.TS_TAILNET }}
    action: test

- name: Comment on PR
  if: always() && github.event_name == 'pull_request'
  env:
    GH_TOKEN: ${{ github.token }}
    OUTCOME: ${{ steps.test-acl.outputs.outcome }}
    OUTPUT: ${{ steps.test-acl.outputs.output }}
  run: |
    # build a comment from $OUTCOME / $OUTPUT and post it with `gh pr comment`

Implementation notes

Changes to the Gitops pusher step in action.yml:

  • Run gitops-pusher with 2>&1 | tee so its output still appears in the log.
  • Keep its exit code, then write the output to $GITHUB_OUTPUT using the multiline heredoc syntax.
  • Declare the new values under outputs: in action.yml.

The step should still exit non-zero when gitops-pusher fails, so existing workflows behave the same.

Optionally, the action could write the same output to $GITHUB_STEP_SUMMARY. That would show failures on the run summary page with no extra workflow setup.

主要言語
言語のデータがありません
スター
153
フォーク
44
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tailscale/gitops-acl-action のほかの issue

tailscale/gitops-acl-action の issue をすべて見る

似ている issue

DevOps の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。