forked from oxsecurity/megalinter
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (93 loc) · 3.96 KB
/
auto-update-linters.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
name: "Auto-Update Linters"
on:
# Run when there is an update in main
push:
branches:
- "main"
- "auto-update"
# Automatically run every day at midnight
schedule:
- cron: "0 0 * * *"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
###############
# Set the Job #
###############
jobs:
build_help_versions:
# Name the Job
name: Auto-Update Linters
# Set the agent to run on
runs-on: ubuntu-latest
# Prevent duplicate run from happening when a forked push is committed
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && github.repository == 'oxsecurity/megalinter'
# Set max build time for the job
timeout-minutes: 60
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
#######################
# Docker Buildx setup #
#######################
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
########################
# Get the current date #
########################
- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}
###################################
# Build image locally for testing #
###################################
- name: Build image
shell: bash
run: docker buildx build --platform linux/amd64,linux/arm64 --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=auto_update_${GITHUB_SHA}" --build-arg "BUILD_VERSION=auto_update_${GITHUB_SHA}" --no-cache -t oxsecurity/megalinter:auto_update_${GITHUB_SHA} --load . | while read line ; do echo "$(date +'%H:%M:%S')| $line"; done;
timeout-minutes: 60
#####################################
# Run Linter against Test code base #
#####################################
- name: Collect latest versions and help
id: compute_versions
shell: bash
run: docker run -e UPGRADE_LINTERS_VERSION=true -e GITHUB_SHA=${GITHUB_SHA} -e GITHUB_TOKEN=${GITHUB_TOKEN} -e PAT="${{secrets.PAT}}" -e GITHUB_OUTPUT="${GITHUB_OUTPUT}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v ${GITHUB_WORKSPACE}:/tmp/lint oxsecurity/megalinter:auto_update_${GITHUB_SHA}
timeout-minutes: 20
# Format markdown tables
- name: Format Markdown tables
id: format-md-tables
run: npx --yes markdown-table-formatter@latest --verbose "./**/*.md" || true
# Upload MegaLinter artifacts
- name: Archive production artifacts
if: ${{ success() }} || ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: MegaLinter reports
path: |
docs
megalinter-reports
# Create pull request if there are updates
- name: Create Pull Request
id: cpr
if: steps.compute_versions.outputs.has_updated_versions == 1
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.PAT }}
author: "Nicolas Vuillamy <[email protected]>"
commit-message: "[automation] Auto-update linters version, help and documentation"
delete-branch: true
title: "[automation] Auto-update linters version, help and documentation"
body: "[automation] Auto-update linters version, help and documentation"
labels: dependencies,automerge
- name: Create PR output
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"