Skip to content

Commit

Permalink
Replace set-output command (#1986)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
parkerbxyz committed Oct 23, 2022
1 parent e957998 commit 2561f74
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .automation/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2757,7 +2757,7 @@ def manage_output_variables():
updated_versions = 1
break
if updated_versions == 1:
print("::set-output name=has_updated_versions::1")
print('"has_updated_versions=1" >>"$GITHUB_OUTPUT"')


def reformat_markdown_tables():
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

prepare:
name: Prepare matrix
runs-on: ubuntu-latest
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.image_tag.outputs.tag }}
steps:
Expand All @@ -40,7 +40,7 @@ jobs:
BRANCH_NAME="${GITHUB_REF##*/}"
TAG="test-${GITHUB_ACTOR}-${BRANCH_NAME}"
echo "Tag name: ${TAG}"
echo "::set-output name=tag::${TAG}"
echo "tag=${TAG}" >>"$GITHUB_OUTPUT"
build:
# Name the Job
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-DEV.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# Get the current date #
########################
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>"$GITHUB_ENV"

########################
# Build image tag name #
Expand All @@ -66,7 +66,7 @@ jobs:
BRANCH_NAME="${GITHUB_REF##*/}"
TAG="test-${GITHUB_ACTOR}-${BRANCH_NAME}"
echo "Tag name: ${TAG}"
echo "::set-output name=tag::${TAG}"
echo "tag=${TAG}" >>"$GITHUB_OUTPUT"
###################################
# Build image locally for testing #
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
##############################################
# Check Docker image security with Trivy #
##############################################

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
Expand All @@ -221,4 +221,4 @@ jobs:
security-checks: vuln
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
timeout: 10m0s
timeout: 10m0s
12 changes: 7 additions & 5 deletions .github/workflows/deploy-RELEASE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
# Only run on main repo
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
environment:
environment:
name: latest
##################
# Load all steps #
Expand Down Expand Up @@ -109,10 +109,12 @@ jobs:
- name: Get release version
id: version
run: |
echo "::set-output name=cversion::$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
echo "::set-output name=ctag::$(git describe --tags --match='v*' --abbrev=0)"
echo "::set-output name=pversion::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1) | cut -c2-)"
echo "::set-output name=ptag::$(git describe --abbrev=0 --match='v*' --tags $(git rev-list --tags --skip=1 --max-count=1))"
{
echo "cversion=$(git describe --tags --match='v*' --abbrev=0 | cut -c2-)"
echo "ctag=$(git describe --tags --match='v*' --abbrev=0)"
echo "pversion=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)" | cut -c2-)"
echo "ptag=$(git describe --abbrev=0 --match='v*' --tags "$(git rev-list --tags --skip=1 --max-count=1)")"
} >>"$GITHUB_OUTPUT"
- name: Print tags
run: |
echo "prev tag ${{ steps.version.outputs.ptag }}"
Expand Down
2 changes: 1 addition & 1 deletion megalinter/MegaLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def display_header():
logging.info("")

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

0 comments on commit 2561f74

Please sign in to comment.