-
Notifications
You must be signed in to change notification settings - Fork 18
90 lines (77 loc) · 3.36 KB
/
update.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
name: Update
on:
pull_request:
paths:
- .github/workflows/update.yml
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
with:
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
lfs: true
fetch-depth: 0 #for better blame info
- name: Get last commit of coraza
id: coraza-latest-commit
run: |
echo "long=$(gh api repos/corazawaf/coraza/commits/main -q .sha)" >> $GITHUB_OUTPUT
echo "short=$(gh api repos/corazawaf/coraza/commits/main -q .sha | cut -c 1-8)" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull latest coraza
run: |
go get -u github.com/corazawaf/coraza/v3@${{ steps.coraza-latest-commit.outputs.long }}
go mod tidy
- name: Tests and coverage
run: go run mage.go test
- name: Generate content
run: go run mage.go generate
- name: Verify Changed files
uses: tj-actions/verify-changed-files@6ed7632824d235029086612d4330d659005af687 # v20
id: verify-changed-files
with:
files: |
content/docs/*
go.mod
go.sum
- name: List changed files
if: ${{ github.event_name == 'pull_request' }}
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
cat <<EOF > $GITHUB_STEP_SUMMARY
# Changed files:
$CHANGED_FILES
# PR information:
**commit-message**: docs: upgrades coraza docs to github.com/corazawaf/coraza/v3@${{ steps.coraza-latest-commit.outputs.short }}
**branch**: upgrades_coraza_${{ steps.coraza-latest-commit.outputs.short }}
**title**: docs: upgrades to latest coraza
**assignees**: ${{ github.actor }}
**body**: This PR upgrades the docs to latest coraza commit namely [${{ steps.coraza-latest-commit.outputs.short }}](https://github.com/corazawaf/coraza/tree/${{ steps.coraza-latest-commit.outputs.long }})
EOF
- name: Create Pull Request
if: ${{ github.event_name != 'pull_request' && steps.verify-changed-files.outputs.files_changed == 'true' }}
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7
id: create-pr
with:
add-paths: content/docs
commit-message: 'docs: upgrades coraza docs to ${{ steps.coraza-latest-commit.outputs.short }}'
signoff: true
branch: upgrades_coraza_${{ steps.coraza-latest-commit.outputs.short }}
title: 'docs: upgrades to latest coraza'
assignees: ${{ github.actor }}
body: |
This PR upgrades the docs to latest coraza commit namely [${{ steps.coraza-latest-commit.outputs.short }}](https://github.com/corazawaf/coraza/tree/${{ steps.coraza-latest-commit.outputs.long }})
- name: Check outputs
if: ${{ github.event_name != 'pull_request' && steps.create-pr.outputs.pull-request-number }}
run: |
echo "Created PR at ${{ steps.create-pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY