Skip to content

Sync files with a different source and destination path #17

Sync files with a different source and destination path

Sync files with a different source and destination path #17

Workflow file for this run

---
name: Megalinter
on:
push:
pull_request:
branches:
- main
workflow_call:
inputs:
GH_APP_ID:
type: string
required: false
secrets:
GH_TOKEN:
required: false
GH_APP_PEM_FILE:
required: false
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
APPLY_FIXES: all
APPLY_FIXES_EVENT: all
APPLY_FIXES_MODE: ${{ github.event_name == 'pull_request' && 'commit' || 'pull_request' }}
jobs:
megalinter:
name: Megalinter
runs-on: ubuntu-latest
permissions:
contents: write # to be able to save fixes
issues: write # to be able to comment on issues
pull-requests: write # to be able to creare new pull requests
env:
USE_GH_APP: ${{ inputs.GH_APP_ID && secrets.GH_APP_PEM_FILE || vars.GH_APP_ML_ID && secrets.GH_APP_ML_PEM_FILE }}
steps:
- name: Create GitHub App token
uses: actions/create-github-app-token@v2
id: gh-app-token
if: env.USE_GH_APP
with:
app-id: ${{ inputs.GH_APP_ID || vars.GH_APP_ML_ID }}
private-key: ${{ secrets.GH_APP_PEM_FILE || secrets.GH_APP_ML_PEM_FILE }}
- name: Checkout repository
uses: actions/checkout@v5
with:
token: ${{ steps.gh-app-token.outputs.token || secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
fetch-depth: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && '1' || '0' }}
- name: Run MegaLinter
id: ml
uses: oxsecurity/megalinter/flavors/documentation@v8
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
GITHUB_TOKEN: ${{ steps.gh-app-token.outputs.token || secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
- name: Upload Megalinter artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
- name: Output short commit SHA
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.ref == 'refs/heads/main'
id: sha
run: echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create Pull Request with applied automatic 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 == 'pull_request' &&
github.ref == 'refs/heads/main'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.gh-app-token.outputs.token || secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
branch: "feature/megalinter-automatic-fixes-for-${{ steps.sha.outputs.short }}"
commit-message: "style: [megalinter] apply automatic fixes"
title: "[MegaLinter] Apply automatic fixes"
labels: bot
- name: Commit and push applied automatic 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'
uses: stefanzweifel/git-auto-commit-action@v6
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
commit_message: "style: [megalinter] apply automatic fixes"
commit_author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>