Ci updates #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull Request Checks | |
on: | |
pull_request: | |
# allow one concurrency | |
concurrency: | |
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref, github.head_ref) }} | |
cancel-in-progress: true | |
jobs: | |
gitleaks: | |
name: "Gitleaks" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run Gitleaks | |
id: gitleaks | |
uses: DariuszPorowski/github-action-gitleaks@v2 | |
with: | |
fail: false | |
- name: Post Gitleaks comment | |
uses: actions/github-script@v7 | |
if: ${{ steps.gitleaks.outputs.exitcode == 1 && github.event_name == 'pull_request' }} | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ` | |
### ${GITLEAKS_RESULT} | |
<details> | |
<summary>Log output</summary> | |
${GITLEAKS_OUTPUT} | |
</details> | |
This was a custom message for the Gitleaks action. | |
` | |
}) | |
env: | |
GITLEAKS_RESULT: ${{ steps.gitleaks.outputs.result }} | |
GITLEAKS_OUTPUT: ${{ steps.gitleaks.outputs.output }} | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ['bug'] | |
}) | |
- name: Post PR comment | |
uses: actions/github-script@v6 | |
if: ${{ steps.gitleaks.outputs.exitcode == 1 && github.event_name == 'pull_request' }} | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
const { GITLEAKS_RESULT, GITLEAKS_OUTPUT } = process.env | |
const output = `### ${GITLEAKS_RESULT} | |
<details> | |
<summary>Log output</summary> | |
${GITLEAKS_OUTPUT} | |
</details> | |
` | |
github.rest.issues.createComment({ | |
...context.repo, | |
issue_number: context.issue.number, | |
body: output | |
}) | |
env: | |
GITLEAKS_RESULT: ${{ steps.gitleaks.outputs.result }} | |
GITLEAKS_OUTPUT: ${{ steps.gitleaks.outputs.output }} | |
lint: | |
name: "Linter" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | |
version: v1.50 | |
build: | |
name: "Build and Test" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v ./... |