Skip to content

hello world app with CI initial test-run #5

hello world app with CI initial test-run

hello world app with CI initial test-run #5

Workflow file for this run

name: CI Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Set working directory
run: cd ./hello-world/
- name: Install dependencies
run: go mod tidy
working-directory: ./hello-world/
- name: Build the application
run: go build -v ./...
working-directory: ./hello-world/
- name: Run unit tests
run: go test -v ./...
working-directory: ./hello-world/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./hello-world
file: ./hello-world/Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/hello-world-server:latest
- name: Install Cosign (Container Signing Tool)
run: |
curl -LO https://github.com/sigstore/cosign/releases/download/v2.0.0/cosign-linux-amd64
chmod +x cosign-linux-amd64
sudo mv cosign-linux-amd64 /usr/local/bin/cosign
- name: Sign Docker image
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" | cosign sign --key - ${{ secrets.DOCKER_USERNAME }}/hello-world-server:latest