-
-
Notifications
You must be signed in to change notification settings - Fork 235
133 lines (121 loc) · 4.68 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
name: "Auto-Update Linters"
on:
# Run when there is an update in main
push:
branches:
- main
- auto-update
- fixes/docgen
# 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
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR
# Remove the ones you do not need
contents: write
issues: write
pull-requests: write
environment:
name: auto-update
# 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}
# Free disk space
- name: Free Disk space
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
###################################
# Build image locally for testing #
###################################
- name: Build MegaLinter Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=auto_update_${{ github.sha }}
BUILD_VERSION=auto_update_${{ github.sha }}
load: true
push: false
secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: |
oxsecurity/megalinter:auto_update_${{ github.sha }}
timeout-minutes: 60
#####################################
# Collect linters versions & help #
#####################################
- 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 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: 60
# 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@v5
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
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 }}"