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

Adds Github Actions #1

Merged
merged 5 commits into from
Nov 23, 2023
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
19 changes: 19 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 📋 Format

on:
push

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v3

- name: 📦 Install Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: 📋 Gofmt
run: go fmt ./...
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint

on:
push

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v3

- name: 📦 Install Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create and Publish a Docker Image

on:
push:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v3

- name: 🔐 Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 📋 Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: ☁️ Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test

on:
push

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v3

- name: 📦 Install Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: 📋 Lint
run: go test ./...
19 changes: 19 additions & 0 deletions .github/workflows/vet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 📋 Vet

on:
push

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v3

- name: 📦 Install Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: 📋 Vet
run: go vet ./...
12 changes: 9 additions & 3 deletions internal/aws/federation/federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package federation
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -40,9 +41,14 @@ func GetSignInLink(credentials aws.Credentials, issuer, dashboardURL string, dur
if err != nil {
return "", fmt.Errorf("failed getting federation URL: %w", err)
}
defer response.Body.Close()
defer func() {
err := response.Body.Close()
if err != nil {
log.Print(err)
}
}()

bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return "", fmt.Errorf("failed reading response body: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/server/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func (s *DashboardServer) Callback(c *gin.Context) {
IdentityPool: s.config.IdentityPool,
IdentityProvider: s.config.IdentityProvider,
})
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}

dashboardURL := cloudwatchdashboard.GetURI(s.config.Region, dashboardName)

Expand Down