From bfb1461112abe976c7e2936f1818a4268d58129f Mon Sep 17 00:00:00 2001 From: No Date: Fri, 12 Jul 2024 20:28:25 -0400 Subject: [PATCH] Fix PDF Action --- .github/workflows/create-pdf.yml | 24 ---------- .github/workflows/mega-linter.yml | 79 +++++++++++++++++++------------ 2 files changed, 49 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/create-pdf.yml diff --git a/.github/workflows/create-pdf.yml b/.github/workflows/create-pdf.yml deleted file mode 100644 index 64a15c6d..00000000 --- a/.github/workflows/create-pdf.yml +++ /dev/null @@ -1,24 +0,0 @@ -on: - push: - paths: - - 'doc/**' - -name: '✏️ Create PDF' - -jobs: - makepdfs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: mkrakowitzer/actions-makepdfs@master - if: github.ref == 'refs/heads/main' - with: - markdown_dir: export - output_dir: export - media_dir: - required: true - default: 'images/' - - uses: actions/upload-artifact@v4 - with: - name: platform-architecture-docs - path: export diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 96337452..9f5215b0 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -1,61 +1,80 @@ +--- # MegaLinter GitHub Action configuration file # More info at https://megalinter.io name: '✏️ MegaLinter' -permissions: - contents: read - on: - workflow_dispatch: + push: pull_request: - branches: - - main - push: - branches: - - main + branches: [master, main] + +env: + APPLY_FIXES: all + APPLY_FIXES_EVENT: pull_request + APPLY_FIXES_MODE: commit concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true -# Comment env block if you do not want to apply fixes -env: - # Apply linter fixes configuration - APPLY_FIXES: all - - # Decide which event triggers application of fixes in a commit or a PR - APPLY_FIXES_EVENT: pull_request, push - - # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) - # or posted in a PR (pull_request) - APPLY_FIXES_MODE: commit - jobs: megalinter: name: MegaLinter runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write steps: - - name: Checkout repository + - name: Checkout Code uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 - # MegaLinter - - name: Run MegaLinter + - name: MegaLinter id: ml uses: oxsecurity/megalinter/flavors/documentation@v7.13.0 env: VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DISABLE: COPYPASTE,SPELL,HTML + DISABLE: COPYPASTE,SPELL,HTML DISABLE_LINTERS: REPOSITORY_GITLEAKS,CSS_SCSS_LINT,BASH_SHELLCHECK,JSON_JSONLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_GIT_DIFF,YAML_V8R,MARKDOWN_MARKDOWNLINT_NO_TRAILING_SPACES,MARKDOWN_MARKDOWNLINT_NO_DUPLICATE_HEADING DISABLE_ERRORS_LINTERS: CSS_STYLELINT,MARKDOWN_MARKDOWN_LINK_CHECK,YAML_YAMLLINT,DOCKERFILE_HADOLINT,REPOSITORY_TRIVY,REPOSITORY_CHECKOV,REPOSITORY_GITLEAKS - MARKDOWN_MARKDOWNLINT_FILTER_REGEX_EXCLUDE: '(export/|briar\.md|donations\.md|LICENSE\.md)' + MARKDOWN_MARKDOWNLINT_FILTER_REGEX_EXCLUDE: '(export/|briar\.md|donations\.md|LICENSE\.md|guide\.md)' - # Upload MegaLinter artifacts - - name: Archive MegaLinter reports + - name: Archive production artifacts + if: success() || failure() uses: actions/upload-artifact@v4 - if: always() # Ensure artifacts are always uploaded with: name: MegaLinter reports path: | megalinter-reports - mega-linter.log \ No newline at end of file + 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.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: nicolas.vuillamy@ox.security \ No newline at end of file