Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pwsh commands #34253

Merged

Conversation

MrHinsh
Copy link
Contributor

@MrHinsh MrHinsh commented Aug 8, 2024

Why:

Currently, in the documentation for workflow-commands-for-github-actions it states that a valid use of PowerShell is:

"$Something" | Out-File -FilePath $env:GITHUB_ENV -Append

However, this does not work for the hosted Ubuntu-Latest agents running with the pwsh shell.

What's being changed:

I have updated all of the powershell commands on this page to be the working format of:

"$Something" >> $env:GITHUB_ENV

Which I have tested produces consistent results.

I have left all older PowerShell commands and only updated the Powershell Core ones.

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

Update all instances of `"something" | Out-File -FilePath $env:GITHUB_ENV  -Append` as this does not work with the shell set to `pwsh` consistently. 

Consistent results were only visible using the ` >> ` mode.
Copy link

welcome bot commented Aug 8, 2024

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Aug 8, 2024
Copy link
Contributor

github-actions bot commented Aug 8, 2024

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions.md fpt
ghec
ghes@ 3.14 3.13 3.12 3.11 3.10
fpt
ghec
ghes@ 3.14 3.13 3.12 3.11 3.10

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server

Per @jessehouwing request I also updated the random generator to be `(New-Guid).Guid` instead of something more complicated.
@MrHinsh MrHinsh changed the title Update workflow-commands-for-github-actions.md Update pwsh commands Aug 8, 2024
@nguyenalex836 nguyenalex836 added content This issue or pull request belongs to the Docs Content team actions This issue or pull request should be reviewed by the docs actions team and removed triage Do not begin working on this issue until triaged by the team labels Aug 8, 2024
@nguyenalex836
Copy link
Contributor

@MrHinsh Thanks so much for opening a PR! I'll get this triaged for review ✨

@nguyenalex836 nguyenalex836 added the waiting for review Issue/PR is waiting for a writer's review label Aug 8, 2024
@subatoi subatoi added the needs SME This proposal needs review from a subject matter expert label Aug 9, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert 👀

Faiqonli

This comment was marked as spam.

@Faiqonli

This comment was marked as spam.

@nguyenalex836 nguyenalex836 removed the waiting for review Issue/PR is waiting for a writer's review label Sep 4, 2024
@nguyenalex836
Copy link
Contributor

@MrHinsh Thank you for your patience while our SME team reviewed your PR! Our SME team responded with the following:

By proposing these changes, won't these commands then not work for windows-latest runners? The doc as-is doesn’t seem to indicate which OS the steps in the doc are for, which might be part of the overall confusion.

If you have any feedback regarding this response, please let us know! 💛

@nguyenalex836 nguyenalex836 added more-information-needed More information is needed to complete review SME reviewed An SME has reviewed this issue/PR and removed needs SME This proposal needs review from a subject matter expert labels Sep 4, 2024
@MrHinsh
Copy link
Contributor Author

MrHinsh commented Sep 4, 2024

I'm positive I've run these as is on Windows agents as well. I'll run a test, but if it works in Powershell it should work in both environments.

@nguyenalex836
Copy link
Contributor

I'm positive I've run these as is on Windows agents as well. I'll run a test, but if it works in Powershell it should work in both environments.

@MrHinsh Sounds like a plan! Let us know what the results of your test are 💛 CC @subatoi just for 👀

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Sep 11, 2024
Copy link
Contributor

This PR has been automatically closed because there has been no response to to our request for more information from the original author. Please reach out if you have the information we requested, or open a new issue to describing your changes. Then we can begin the review process.

@github-actions github-actions bot closed this Sep 11, 2024
@MrHinsh
Copy link
Contributor Author

MrHinsh commented Sep 12, 2024

How do i reopen this?

@subatoi subatoi reopened this Sep 12, 2024
@subatoi
Copy link
Contributor

subatoi commented Sep 12, 2024

Apologies about the aggressive automation @MrHinsh

@github-actions github-actions bot removed the stale There is no recent activity on this issue or pull request label Sep 12, 2024
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Sep 12, 2024
@MrHinsh
Copy link
Contributor Author

MrHinsh commented Sep 12, 2024

Ive tested this for both Ubuntu and Windows: https://github.com/MrHinsh/pwsh-command-test/actions/runs/10825655461

I created the following build:

name: Test Setup

on:
  push:
    branches: ["*"]
  workflow_dispatch:

defaults:
  run:
    shell: pwsh

jobs:

   # Setup & Configuration
  SetupWin:
    name: "Windows Test"
    runs-on: windows-latest
    outputs:
      TestSetupWin: ${{ steps.nkdagility.outputs.TestSetupWin }}      
    steps:
    - name: "Build NKDAgility Outputs"
      shell: pwsh
      id: nkdagility
      run: |
            echo "TestSetupWin=sucess" >> $env:GITHUB_OUTPUT

   # Setup & Configuration
  SetupUbntu:
    name: "Ubuntu Test"
    runs-on: ubuntu-latest
    outputs:
      TestSetupUn: ${{ steps.nkdagility.outputs.TestSetupUn }}      
    steps:
    - name: "Build NKDAgility Outputs"
      shell: pwsh
      id: nkdagility
      run: |
            echo "TestSetupUn=sucess" >> $env:GITHUB_OUTPUT


  # Setup Validator
  SetupSummeryStage:
    name: "Results"
    runs-on: ubuntu-latest
    needs: [SetupWin, SetupUbntu]
    steps:
    - name: "Show Summery"
      if: always()
      shell: pwsh
      id: nkdagility-summery
      run: |
            $markdown = @"
                 - TestSetupWin: ${{needs.SetupWin.outputs.TestSetupWin}}
                 - TestSetupUn: ${{needs.SetupUbntu.outputs.TestSetupUn}}
            "@
            echo $markdown >> $Env:GITHUB_STEP_SUMMARY


This build uses echo "TestSetupWin=sucess" >> $env:GITHUB_OUTPUT to set a variable both through ubuntu-latest and through windows-latest with the same results:

image

Please feel free to check my work.

Repo: https://github.com/MrHinsh/pwsh-command-test/
Action: https://github.com/MrHinsh/pwsh-command-test/actions/workflows/main.yml

Result: https://github.com/MrHinsh/pwsh-command-test/actions/runs/10825739503

@nguyenalex836 does this address the concern?

@nguyenalex836
Copy link
Contributor

@MrHinsh Thank you for testing and posting your results! ✨ I'm going to ping the SME who initially reviewed this PR to review these results as well. We'll provide an update once the review is finished 💛

@nguyenalex836 nguyenalex836 removed triage Do not begin working on this issue until triaged by the team more-information-needed More information is needed to complete review labels Sep 12, 2024
@nguyenalex836
Copy link
Contributor

@MrHinsh Our SME just reviewed your results, and everything looks perfect! ✨ Thank you for taking the time to draft this PR and sharing your test results 💛

This repo is currently in a code freeze, but we will get this merged as soon as the freeze ends on 9/16 🍏

@nguyenalex836 nguyenalex836 added the ready to merge This pull request is ready to merge label Sep 12, 2024
@nguyenalex836 nguyenalex836 added this pull request to the merge queue Sep 16, 2024
Merged via the queue into github:main with commit dea8b18 Sep 16, 2024
46 checks passed
Copy link
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team ready to merge This pull request is ready to merge SME reviewed An SME has reviewed this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants