forked from ArmDeveloperEcosystem/arm-learning-paths
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (93 loc) · 3.5 KB
/
maintenance.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
# This workflow check instructions in articles
name: Maintenance workflow
# Controls when the action will run.
on:
# Triggers the workflow on the 1st every month. Disable for now
#schedule:
# - cron: '* * 1 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Generate report of outdated articles
report:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Check out repo and the whole history
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Report outdated files, store result as artifact and updates stats
- name: Report outdated files of more than 20 days
run: |
pip install -r tools/requirements.txt
python3 tools/maintenance.py -r 20
# Upload report as artifact
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: outdated
path: outdated_files.csv
# Test content of outdated articles
test:
# The type of runner that the job will run on
runs-on: self-hosted
# Depends on report generated in previous step
needs: report
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Check out repo
- name: Check out repository code
uses: actions/checkout@v4
# Download list of outdated files to test
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: outdated
# Run tests for install guides
- name: Test commands and output reports for intall-guides
run: |
for i in $(tree -i -f content/install-guides/ | tail -n +2 | grep ".md$"); do
python3 tools/maintenance.py -i $i -l ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
done
# Run tests for learning paths
#- name: Test commands and output reports for learning paths
# run: |
# for i in $(tree -i -d -f content/learning-paths/ | tail -n +2); do
# python3 tools/maintenance.py -i $i -l ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
# done
# Move reports to result folder
- name: Move reports
run: |
mkdir junit-reports
for i in $(tree -i -f | grep "_cmd.xml"); do
mv $i junit-reports/
done
# Upload test reports as artifact
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: results
path: junit-reports/*_cmd.xml
# Publish Junit reports
- name: Publish Test Reports
id: junit
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/junit-reports/*_cmd.xml'
detailed_summary: true
include_passed: true
# Commit and push changes
- name: Commit test status
run: |
git config user.name github-actions
git config user.email [email protected]
git ls-files --modified | xargs git add
git pull
if git commit -m "Add test status"; then
git push
fi