|
1 | | -name: Release New Version |
| 1 | +name: CodeQL |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | 4 | push: |
6 | 5 | branches: |
7 | 6 | - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + schedule: |
| 11 | + - cron: '45 13 * * *' |
8 | 12 |
|
9 | 13 | jobs: |
10 | | - # Builds a new release for the module by bumping the version number and |
11 | | - # generating a changelog entry. Commit the changes and open a pull request. |
12 | | - build-release: |
13 | | - name: Build new release |
14 | | - runs-on: ubuntu-latest |
15 | | - if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }} |
| 14 | + analyze: |
| 15 | + name: Analyze (${{ matrix.language }}) |
| 16 | + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} |
16 | 17 | permissions: |
17 | | - contents: write |
18 | | - pull-requests: write |
| 18 | + security-events: write |
| 19 | + packages: read |
| 20 | + actions: read |
| 21 | + contents: read |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - language: actions |
| 27 | + build_mode: none |
19 | 28 | steps: |
20 | | - - name: Checkout source code |
| 29 | + - name: Checkout repository |
21 | 30 | uses: actions/checkout@v6 |
| 31 | + - name: Initialize CodeQL |
| 32 | + uses: github/codeql-action/init@v4 |
22 | 33 | with: |
23 | | - fetch-depth: 0 |
24 | | - - name: Bump version and create changelog |
25 | | - id: bump |
26 | | - uses: commitizen-tools/commitizen-action@0.27.0 |
27 | | - with: |
28 | | - push: false |
29 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
30 | | - git_redirect_stderr: true |
31 | | - - name: Get the commit message |
32 | | - id: message |
33 | | - run: | |
34 | | - MESSAGE=$(git log --format=%B -n 1) |
35 | | - echo "message=${MESSAGE}" >> $GITHUB_OUTPUT |
36 | | - - name: Open a pull request for the release |
37 | | - uses: peter-evans/create-pull-request@v8 |
| 34 | + languages: ${{ matrix.language }} |
| 35 | + build-mode: ${{ matrix.build-mode }} |
| 36 | + - name: Perform CodeQL Analysis |
| 37 | + uses: github/codeql-action/analyze@v4 |
38 | 38 | with: |
39 | | - branch: release-${{ steps.bump.outputs.version }} |
40 | | - title: ${{ steps.message.outputs.message }} |
41 | | - |
42 | | - # Creates a new tag and GitHub release for the module. |
43 | | - release: |
44 | | - name: Release module |
45 | | - runs-on: ubuntu-latest |
46 | | - if: startsWith(github.event.head_commit.message, 'bump:') |
47 | | - permissions: |
48 | | - contents: write |
49 | | - steps: |
50 | | - - name: Checkout source code |
51 | | - uses: actions/checkout@v6 |
52 | | - - name: Get the module name |
53 | | - id: module_name |
54 | | - run: | |
55 | | - REPO_NAME="${{ github.event.repository.name }}" |
56 | | - REPO_NAME="${REPO_NAME/tofu-modules-/}" |
57 | | - MODULE_NAME="${REPO_NAME//-/_}" |
58 | | - echo "name=${MODULE_NAME}" >> $GITHUB_OUTPUT |
59 | | - - name: Get the version from the commit message |
60 | | - id: version |
61 | | - uses: actions/github-script@v8 |
62 | | - env: |
63 | | - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} |
64 | | - with: |
65 | | - result-encoding: string |
66 | | - # Look for the last version number, expecting it to be in the format: |
67 | | - # `#.#.#-<suffix>.#` where the suffix is optional. |
68 | | - script: | |
69 | | - const message = process.env.COMMIT_MESSAGE; |
70 | | - const regex = /^bump:.+(?<version>\d+\.\d+\.\d+[\da-z.-]*) \(#\d+\)$/m; |
71 | | - const version = message.match(regex).groups.version; |
72 | | - console.log(version); |
73 | | - return version; |
74 | | - - name: Bundle the module |
75 | | - # We create an empty file first, so that tar doesn't complain about the |
76 | | - # contents changing while it's running. |
77 | | - run: | |
78 | | - touch '${{ steps.module_name.outputs.name }}-${{ steps.version.outputs.result }}.tar.gz' |
79 | | - tar \ |
80 | | - --exclude='.git' \ |
81 | | - --exclude='.gitignore' \ |
82 | | - --exclude='.github' \ |
83 | | - --exclude='.cz.yaml' \ |
84 | | - --exclude='*.tar.gz' \ |
85 | | - --exclude='*.tfvars' \ |
86 | | - --exclude='release.md' \ |
87 | | - --exclude='CODEOWNERS' \ |
88 | | - --exclude='trivy.yaml' \ |
89 | | - --exclude='*.env' \ |
90 | | - -czf '${{ steps.module_name.outputs.name }}-${{ steps.version.outputs.result }}.tar.gz' \ |
91 | | - . |
92 | | - - name: Get changelog entry |
93 | | - id: changelog |
94 | | - uses: artlaman/conventional-changelog-reader-action@v1.1.0 |
95 | | - with: |
96 | | - version: ${{ steps.version.outputs.result }} |
97 | | - - name: Create release |
98 | | - uses: softprops/action-gh-release@v2 |
99 | | - with: |
100 | | - body: | |
101 | | - ## ${{ steps.changelog.outputs.version }} (${{ steps.changelog.outputs.date }}) |
102 | | -
|
103 | | - ${{ steps.changelog.outputs.changes }} |
104 | | - tag_name: ${{ steps.version.outputs.result }} |
105 | | - files: | |
106 | | - ${{ steps.module_name.outputs.name }}-${{ steps.version.outputs.result }}.tar.gz |
| 39 | + category: "/language:${{matrix.language}}" |
0 commit comments