diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e0cb3a3..be1d048 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,14 +23,18 @@ jobs: cp test/buf.bash tmp/bin/buf chmod +x tmp/bin/buf echo "${PWD}/tmp/bin" >> "${GITHUB_PATH}" - - name: run action - if: github.ref == 'refs/heads/main' + - name: run on branch + if: github.ref_type == 'branch' && github.ref != 'refs/heads/main' uses: ./ with: buf_token: fake-buf-token input: path/to/input + env: + WANT_BUF_TOKEN: fake-buf-token + WANT_ARGS: push path/to/input --draft ${{ github.ref_name }} + - name: run on main + if: github.ref_type == 'branch' && github.ref == 'refs/heads/main' + run: "echo $WANT_ARGS" env: WANT_BUF_TOKEN: fake-buf-token WANT_ARGS: push path/to/input --tag ${{ github.sha }} - GITHUB_REF_TYPE: branch - GITHUB_REF_NAME: main diff --git a/push.bash b/push.bash index 6989759..0e2421a 100755 --- a/push.bash +++ b/push.bash @@ -41,8 +41,13 @@ if [ -z "$BUF_COMMAND" ]; then fail "$NOT_INSTALLED_MESSAGE" fi +if [ "${GITHUB_REF_TYPE}" != "branch" ]; then + echo "reference type is not branch, skipping" >&2 + exit 0 +fi + BUF_ARGS=("--tag" "${GITHUB_SHA}") -if [ "${GITHUB_REF_TYPE}" = "branch" ] && [ "${GITHUB_REF_NAME}" != "main" ]; then +if [ "${GITHUB_REF}" != "refs/heads/main" ]; then # Check that --draft is supported by running "buf push --draft example --help" # and checking for "unknown flag: --draft" in the output. set +e