Skip to content

Commit

Permalink
Refactor using actions/github-script
Browse files Browse the repository at this point in the history
  • Loading branch information
masutaka committed Sep 26, 2024
1 parent 99702cb commit 826ccb7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 10
outputs:
languages: ${{ steps.formatted_filters.outputs.languages }}
languages: ${{ steps.format.outputs.languages }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -110,18 +110,24 @@ jobs:
- added|modified: '**/*.plist'
- added|modified: '**/*.storyboard'
- added|modified: '**/*.xib'
- name: format filters result
id: formatted_filters
run: |
languages="["
[[ ${{ steps.filter.outputs.go }} == true ]] && languages+='"go",'
[[ ${{ steps.filter.outputs.javascript }} == true ]] && languages+='"javascript",'
[[ ${{ steps.filter.outputs.python }} == true ]] && languages+='"python",'
[[ ${{ steps.filter.outputs.ruby }} == true ]] && languages+='"ruby",'
[[ ${{ steps.filter.outputs.java }} == true ]] && languages+='"java,'
[[ ${{ steps.filter.outputs.swift }} == true ]] && languages+='"swift,'
languages="${languages%,}]"
echo "languages=$languages" >> "$GITHUB_OUTPUT"
- name: Format filtered languages
id: format
uses: actions/github-script@v7
with:
script: |
const outputs = {
go: ${{ steps.filter.outputs.go }},
javascript: ${{ steps.filter.outputs.javascript }},
python: ${{ steps.filter.outputs.python }},
ruby: ${{ steps.filter.outputs.ruby }},
java: ${{ steps.filter.outputs.java }},
swift: ${{ steps.filter.outputs.swift }},
};
const languages = Object.keys(outputs)
.filter(lang => outputs[lang]);
core.setOutput('languages', JSON.stringify(languages));
languages:
needs: changes
Expand Down

0 comments on commit 826ccb7

Please sign in to comment.