updated #6
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: Go Build and PR Management | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
issues: | |
types: [opened] | |
workflow_dispatch: | |
env: | |
GO_VERSION: '1.22.6' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [blog, bookstore-api, chatapp, databasecrud, fileserver, gin-practice, gin-server, ginnn, ginnn2, github-client-go, jsontoexcelconverter, nutrition-calculator, online-compiler, platform, postman-clone, quiz-cli, restful, server, server2, server3, std-server, sportsstore, task_processor, todoapp, url-shortener, users] | |
steps: | |
- name: Set up Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Build | |
run: go build -ldflags="-w" ./... | |
working-directory: ${{ matrix.project }} | |
- name: Test | |
run: go test -v ./... 2>&1 | grep -vE "warning_pattern_here" | |
working-directory: ${{ matrix.project }} | |
greeting: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Greeting on PR | |
if: github.event_name == 'pull_request' | |
uses: actions/first-interaction@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
pr-message: "Message that will be displayed on users' first pull request" | |
- name: Greeting on Issue | |
if: github.event_name == 'issues' | |
uses: actions/first-interaction@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
issue-message: "Thank you for opening an issue! We appreciate your contribution and will review it shortly." | |
welcome: | |
name: Welcome | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' && github.event.action == 'opened' | |
steps: | |
- name: Welcome PR | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const issueComment = `Hello @${{ github.actor }}, thank you for your contribution!`; | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: issueComment | |
}); |