diff mbox series

[v2] CI: migrate away from deprecated "set-output" syntax

Message ID patch-v2-1.1-4e7db0db3be-20221207T014848Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2] CI: migrate away from deprecated "set-output" syntax | expand

Commit Message

Ævar Arnfjörð Bjarmason Dec. 7, 2022, 1:49 a.m. UTC
As noted in [1] and the warnings the CI itself is spewing echoing
outputs to stdout is deprecated, and they should be written to
"$GITHUB_OUTPUT" instead.

1. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
Range-diff against v1:
1:  deb65805345 ! 1:  4e7db0db3be CI: migrate away from deprecated "set-output" syntax
    @@ Commit message
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
    + ## .github/workflows/l10n.yml ##
    +@@ .github/workflows/l10n.yml: jobs:
    +             base=${{ github.event.before }}
    +             head=${{ github.event.after }}
    +           fi
    +-          echo "::set-output name=base::$base"
    +-          echo "::set-output name=head::$head"
    ++          cat >>$GITHUB_OUTPUT <<-EOF
    ++          base=$base
    ++          head=$head
    ++          EOF
    +       - name: Run partial clone
    +         run: |
    +           git -c init.defaultBranch=master init --bare .
    +
      ## .github/workflows/main.yml ##
     @@ .github/workflows/main.yml: jobs:
                then

 .github/workflows/l10n.yml | 6 ++++--
 .github/workflows/main.yml | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Junio C Hamano Dec. 7, 2022, 11:57 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

>     +-          echo "::set-output name=base::$base"
>     +-          echo "::set-output name=head::$head"
>     ++          cat >>$GITHUB_OUTPUT <<-EOF
>     ++          base=$base
>     ++          head=$head
>     ++          EOF

Hmph, I do not trust this part.

The redirection operator "<<-" causes the leading tabs in the
here-doc-text stripped, but the .yml file does not indent with tab
to begin with.

I suspect the leading spaces will all be stripped and not seen by
the shell, so the distinction may not matter, which means the use of
"<<-" is very much misleading.

Let's stick to the dumb and proven

	echo "base=$base" >>$GITHUB_OUTPUT
	echo "head=$head" >>$GITHUB_OUTPUT

instead, which is used throughout the rewrite in this patch.
Ævar Arnfjörð Bjarmason Dec. 8, 2022, 12:27 a.m. UTC | #2
On Thu, Dec 08 2022, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>>     +-          echo "::set-output name=base::$base"
>>     +-          echo "::set-output name=head::$head"
>>     ++          cat >>$GITHUB_OUTPUT <<-EOF
>>     ++          base=$base
>>     ++          head=$head
>>     ++          EOF
>
> Hmph, I do not trust this part.
>
> The redirection operator "<<-" causes the leading tabs in the
> here-doc-text stripped, but the .yml file does not indent with tab
> to begin with.
>
> I suspect the leading spaces will all be stripped and not seen by
> the shell, so the distinction may not matter, which means the use of
> "<<-" is very much misleading.
>
> Let's stick to the dumb and proven
>
> 	echo "base=$base" >>$GITHUB_OUTPUT
> 	echo "head=$head" >>$GITHUB_OUTPUT
>
> instead, which is used throughout the rewrite in this patch.

Sure, I'll re-roll with that.
Junio C Hamano Dec. 8, 2022, 5:41 a.m. UTC | #3
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> Let's stick to the dumb and proven
>>
>> 	echo "base=$base" >>$GITHUB_OUTPUT
>> 	echo "head=$head" >>$GITHUB_OUTPUT
>>
>> instead, which is used throughout the rewrite in this patch.
>
> Sure, I'll re-roll with that.

Ah, no need.  I've already amended the one under discussion and it
is in 'next' together with the last bit from Johannes to use the
updated upload/download artifact Action.

Thanks.
diff mbox series

Patch

diff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml
index 27f72f0ff34..8fa073db2dc 100644
--- a/.github/workflows/l10n.yml
+++ b/.github/workflows/l10n.yml
@@ -23,8 +23,10 @@  jobs:
             base=${{ github.event.before }}
             head=${{ github.event.after }}
           fi
-          echo "::set-output name=base::$base"
-          echo "::set-output name=head::$head"
+          cat >>$GITHUB_OUTPUT <<-EOF
+          base=$base
+          head=$head
+          EOF
       - name: Run partial clone
         run: |
           git -c init.defaultBranch=master init --bare .
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9afacfa0b33..d1e16009b11 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -34,7 +34,7 @@  jobs:
           then
             enabled=no
           fi
-          echo "::set-output name=enabled::$enabled"
+          echo "enabled=$enabled" >>$GITHUB_OUTPUT
       - name: skip if the commit or tree was already tested
         id: skip-if-redundant
         uses: actions/github-script@v6