Skip to content

Commit

Permalink
added actions
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Aug 21, 2023
1 parent e563ab8 commit 6939af9
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
File renamed without changes.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.1

- name: Install dependencies
run: go get .

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

# - name: Build the Docker image
# run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}




42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
release:
types: [published]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ulboralabs/go-micro-blog

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

#RUN sudo apt-get update
RUN apt-get update
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A micro blog service in golang.
Built with GolangToolKits/grrt, a drop-in replacement for gorilla/mux which is no longer maintained.

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Ulbora_go-micro-blog&metric=alert_status)](https://sonarcloud.io/dashboard?id=Ulbora_go-micro-blog)
[![CircleCI](https://circleci.com/gh/Ulbora/go-micro-blog.svg?style=svg)](https://circleci.com/gh/Ulbora/go-micro-blog)
[![GitHub Actions Build](https://github.com/Ulbora/go-micro-blog/actions/workflows/build.yml/badge.svg)](https://github.com/Ulbora/go-micro-blog/actions/workflows/build.yml)
<!-- [![CircleCI](https://circleci.com/gh/Ulbora/go-micro-blog.svg?style=svg)](https://circleci.com/gh/Ulbora/go-micro-blog) -->
[![Go Report Card](https://goreportcard.com/badge/github.com/Ulbora/go-micro-blog)](https://goreportcard.com/report/github.com/Ulbora/go-micro-blog)

0 comments on commit 6939af9

Please sign in to comment.