Skip to content

fix: copy pasta

fix: copy pasta #176

Workflow file for this run

---
name: MegaLinter
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
workflow_dispatch: null
workflow_call: null
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
steps:
- name: Set up node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Checkout
uses: actions/checkout@v4
- name: Copy linting config from r.workflows/main
shell: bash
run: |
echo ===========
echo "$GITHUB_REPOSITORY"
echo "$GITHUB_HEAD_REF"
echo "$GITHUB_REF_NAME"
echo ===========
if [ "$GITHUB_REPOSITORY" = "NovoNordisk-OpenSource/r.workflows" ]; then
workflow_branch="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
echo =========
echo Using "${workflow_branch}"
echo =========
else
workflow_branch="main"
fi
if [ ! -e ".mega-linter.yml" ]; then
echo "==> Adding .mega-linter.yml"
curl --output .mega-linter.yml "https://raw.githubusercontent.com/NovoNordisk-OpenSource/r.workflows/${workflow_branch}/.github/linters/.mega-linter.yml"
fi
if [ ! -e ".lintr" ]; then
echo "==> Adding .lintr"
curl --output .lintr "https://raw.githubusercontent.com/NovoNordisk-OpenSource/r.workflows/${workflow_branch}/.github/linters/.lintr"
fi
if [ ! -e ".lycheeignore" ]; then
echo "==> Adding .lycheeignore"
curl --output .lycheeignore "https://raw.githubusercontent.com/NovoNordisk-OpenSource/r.workflows/${workflow_branch}/.github/linters/.lycheeignore"
fi
if [ ! -e ".cspell.json" ]; then
echo "==> Adding .cspell.json"
if [ -e "inst/WORDLIST" ]; then
curl --output .cspell.json "https://raw.githubusercontent.com/NovoNordisk-OpenSource/r.workflows/${workflow_branch}/.github/linters/.cspell-wordlist.json"
else
curl --output .cspell.json "https://raw.githubusercontent.com/NovoNordisk-OpenSource/r.workflows/${workflow_branch}/.github/linters/.cspell.json"
fi
fi
- name: MegaLinter
id: ml
uses: oxsecurity/megalinter@latest
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
APPLY_FIXES: all
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: pull_request
- name: Archive production artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
- name: Create Pull Request with applied fixes
id: cpr
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all'
|| env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE
== 'pull_request' && (github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository) &&
!contains(github.event.head_commit.message, 'skip fix')
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.access-token || secrets.ACTION_PAT || secrets.GITHUB_TOKEN}}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot
- name: Create PR output
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all'
|| env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE
== 'pull_request' && (github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository) &&
!contains(github.event.head_commit.message, 'skip fix')
run: >
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Prepare commit
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all'
|| env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE
== 'commit' && github.ref != 'refs/heads/main' && (github.event_name
== 'push' || github.event.pull_request.head.repo.full_name ==
github.repository) && !contains(github.event.head_commit.message,
'skip fix')
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all'
|| env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE
== 'commit' && github.ref != 'refs/heads/main' && (github.event_name
== 'push' || github.event.pull_request.head.repo.full_name ==
github.repository) && !contains(github.event.head_commit.message,
'skip fix')
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: actions-robot@novonordisk.com