Last active
January 14, 2024 18:11
-
-
Save philip-gai/2b21293b178aa6ea6903e99cc1c32c4f to your computer and use it in GitHub Desktop.
Revisions
-
philip-gai revised this gist
Mar 30, 2022 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,20 +4,17 @@ # # Notes: # - You can tell that it works because it masks the secret_body in the echo secret step after it creates the secret 😄 # - If you don't want to have to pass --repo to gh secret set, then put the actions/checkout@v2 step before the gh secret set step name: gh-set-secret on: workflow_dispatch: env: pat_token: ${{ secrets.PAT_TOKEN }} # Permissions: repo (all) and read:org secret_name: HELLO_WORLD secret_body: "Hello World!" secret_environment: sandbox jobs: @@ -26,18 +23,21 @@ jobs: steps: - name: gh auth login shell: bash run: gh auth login --with-token <<< $pat_token - name: gh secret set env shell: bash run: | repository='${{ github.repository }}' gh secret set "$secret_name" --env "$secret_environment" --body "$secret_body" --repo $repository gh-test-secret: needs: [gh-set-secret] runs-on: ubuntu-latest environment: name: sandbox env: secret: ${{ secrets.HELLO_WORLD }} steps: - name: echo secret shell: bash run: | echo "Secret: $secret" -
philip-gai created this gist
Nov 5, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ # Prerequisites: # - Create a secret with your PAT token. Permissions needed: repo (all) and read:org # - Create the HELLO_WORLD secret in your environment with some dummy initial value # # Notes: # - You can tell that it works because it masks the secret_body in the echo secret step after it creates the secret 😄 # - If you don't want to have to call gh auth login, set the env var GH_TOKEN or GITHUB_TOKEN to ${{ secrets.PAT_TOKEN }} and skip that step # - If you don't want to have to pass --repo to gh secret set, then put the actions/checkout@v2 step before the gh secret set step # name: gh-set-secret on: workflow_dispatch: env: pat_token: ${{ secrets.PAT_TOKEN }} secret_name: HELLO_WORLD secret_body: "Hello World!" secret_repo: "philip-gai/philip-gai" secret_environment: sandbox jobs: gh-set-secret: runs-on: ubuntu-latest steps: - name: gh auth login shell: bash run: gh auth login --with-token <<< "${{ env.pat_token }}" - name: gh secret set env shell: bash run: gh secret set "${{ env.secret_name }}" --env "${{ env.secret_environment }}" --body "${{ env.secret_body }}" --repo "${{ env.secret_repo }}" gh-test-secret: needs: [gh-set-secret] runs-on: ubuntu-latest environment: name: ${{ env.secret_environment }} env: secret: ${{ secrets.HELLO_WORLD }} steps: - name: echo secret shell: bash run: echo "$HELLO_WORLD"