Skip to content

Commit 2561f74

Browse files
authored
Replace set-output command (#1986)
* Replace `set-output` command * Consolidate redirects Use `{ cmd1; cmd2; } >> file` instead of individual redirects per shellcheck ([SC2129](https://www.shellcheck.net/wiki/SC2129)). * Double quote to prevent globbing and word splitting * Replace `set-output` in Python scripts
1 parent e957998 commit 2561f74

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

.automation/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,7 +2757,7 @@ def manage_output_variables():
27572757
updated_versions = 1
27582758
break
27592759
if updated_versions == 1:
2760-
print("::set-output name=has_updated_versions::1")
2760+
print('"has_updated_versions=1" >>"$GITHUB_OUTPUT"')
27612761

27622762

27632763
def reformat_markdown_tables():

.github/workflows/deploy-DEV-linters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
prepare:
3131
name: Prepare matrix
32-
runs-on: ubuntu-latest
32+
runs-on: ubuntu-latest
3333
outputs:
3434
tag: ${{ steps.image_tag.outputs.tag }}
3535
steps:
@@ -40,7 +40,7 @@ jobs:
4040
BRANCH_NAME="${GITHUB_REF##*/}"
4141
TAG="test-${GITHUB_ACTOR}-${BRANCH_NAME}"
4242
echo "Tag name: ${TAG}"
43-
echo "::set-output name=tag::${TAG}"
43+
echo "tag=${TAG}" >>"$GITHUB_OUTPUT"
4444
4545
build:
4646
# Name the Job

.github/workflows/deploy-DEV.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
# Get the current date #
5656
########################
5757
- name: Get current date
58-
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
58+
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>"$GITHUB_ENV"
5959

6060
########################
6161
# Build image tag name #
@@ -66,7 +66,7 @@ jobs:
6666
BRANCH_NAME="${GITHUB_REF##*/}"
6767
TAG="test-${GITHUB_ACTOR}-${BRANCH_NAME}"
6868
echo "Tag name: ${TAG}"
69-
echo "::set-output name=tag::${TAG}"
69+
echo "tag=${TAG}" >>"$GITHUB_OUTPUT"
7070
7171
###################################
7272
# Build image locally for testing #
@@ -210,7 +210,7 @@ jobs:
210210
##############################################
211211
# Check Docker image security with Trivy #
212212
##############################################
213-
213+
214214
- name: Run Trivy vulnerability scanner
215215
uses: aquasecurity/trivy-action@master
216216
with:
@@ -221,4 +221,4 @@ jobs:
221221
security-checks: vuln
222222
vuln-type: 'os,library'
223223
severity: 'CRITICAL,HIGH'
224-
timeout: 10m0s
224+
timeout: 10m0s

.github/workflows/deploy-RELEASE.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
runs-on: ubuntu-latest
3838
# Only run on main repo
3939
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
40-
environment:
40+
environment:
4141
name: latest
4242
##################
4343
# Load all steps #
@@ -109,10 +109,12 @@ jobs:
109109
- name: Get release version
110110
id: version
111111
run: |
112-
echo "::set-output name=cversion::$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
113-
echo "::set-output name=ctag::$(git describe --tags --match='v*' --abbrev=0)"
114-
echo "::set-output name=pversion::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1) | cut -c2-)"
115-
echo "::set-output name=ptag::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1))"
112+
{
113+
echo "cversion=$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
114+
echo "ctag=$(git describe --tags --match='v*' --abbrev=0)"
115+
echo "pversion=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)" | cut -c2-)"
116+
echo "ptag=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)")"
117+
} >>"$GITHUB_OUTPUT"
116118
- name: Print tags
117119
run: |
118120
echo "prev tag ${{ steps.version.outputs.ptag }}"

megalinter/MegaLinter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def display_header():
822822
logging.info("")
823823

824824
def check_results(self):
825-
print(f"::set-output name=has_updated_sources::{str(self.has_updated_sources)}")
825+
print(f'"has_updated_sources={str(self.has_updated_sources)}" >>"$GITHUB_OUTPUT"')
826826
if self.status == "success":
827827
logging.info(c.green("✅ Successfully linted all files without errors"))
828828
config.delete()

0 commit comments

Comments
 (0)