Browse Source

ci: use GitHub env vars instead of contexts

Paul Razvan Berg 2 years ago
parent
commit
43183255f0
2 changed files with 8 additions and 11 deletions
  1. 7 7
      .github/scripts/rename.sh
  2. 1 4
      .github/workflows/create.yml

+ 7 - 7
.github/scripts/rename.sh

@@ -4,17 +4,17 @@
 set -euo pipefail
 set -euo pipefail
 
 
 # Define the input vars
 # Define the input vars
-REPOSITORY=${1?Error: Please pass username/repo, e.g. prb/hardhat-template}
-REPOSITORY_OWNER=${2?Error: Please pass username, e.g. prb}
+GITHUB_REPOSITORY=${1?Error: Please pass username/repo, e.g. prb/hardhat-template}
+GITHUB_REPOSITORY_OWNER=${2?Error: Please pass username, e.g. prb}
 
 
-echo "REPOSITORY: $REPOSITORY"
-echo "REPOSITORY_OWNER: $REPOSITORY_OWNER"
+echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
+echo "GITHUB_REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER"
 
 
 # jq is like sed for JSON data
 # jq is like sed for JSON data
 JQ_OUTPUT=`jq \
 JQ_OUTPUT=`jq \
-  --arg NAME "@$REPOSITORY" \
-  --arg AUTHOR_NAME "$REPOSITORY_OWNER" \
-  --arg URL "https://github.com/$REPOSITORY_OWNER" \
+  --arg NAME "@$GITHUB_REPOSITORY" \
+  --arg AUTHOR_NAME "$GITHUB_REPOSITORY_OWNER" \
+  --arg URL "https://github.com/$GITHUB_REPOSITORY_OWNER" \
   '.name = $NAME | .description = "" | .author |= ( .name = $AUTHOR_NAME | .url = $URL )' \
   '.name = $NAME | .description = "" | .author |= ( .name = $AUTHOR_NAME | .url = $URL )' \
   package.json
   package.json
 `
 `

+ 1 - 4
.github/workflows/create.yml

@@ -19,10 +19,7 @@ jobs:
         uses: "actions/checkout@v3"
         uses: "actions/checkout@v3"
 
 
       - name: "Update package.json"
       - name: "Update package.json"
-        env:
-          REPOSITORY: ${{ github.repository }}
-          REPOSITORY_OWNER: ${{ github.repository_owner }}
-        run: ./.github/scripts/rename.sh "$REPOSITORY" "$REPOSITORY_OWNER"
+        run: ./.github/scripts/rename.sh "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER"
 
 
       - name: "Add rename summary"
       - name: "Add rename summary"
         run: |
         run: |