Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not feature/back/ci cd #12

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CD Workflow

on:
pull_request:
types:
- closed
branches:
- main

jobs:
build-and-deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v3


- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'


- name: Build binary
run: go build -o rpl-service ../../main/main.go

- name: Upload Go artifact
uses: actions/upload-artifact@v4
with:
name: rpl-service
path: rpl-service


- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
with:
github-token: ${{ secrets.DEPLOY_TOKEN }}
pages-branch: main
pages-path: /
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI Workflow

on:
pull_request:
branches:
- main
- dev
push:
branches-ignore:
- main

jobs:
lint-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Check formatting with gofmt
run: |
echo "Checking code formatting with gofmt..."
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "The following files are not formatted:"
echo "$unformatted"
exit 1
fi

- name: Run golint
run: golint ./... || exit 1

- name: Run tests
run: go test ./... -v
8 changes: 8 additions & 0 deletions main/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "fmt"

func main() {
// Should run the main web application
fmt.Println("Hello World!")
}