hello world app with CI initial test-run #1
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: 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: Install dependencies | |
run: go mod tidy | |
- name: Build the application | |
run: go build -v ./... | |
- name: Run unit tests | |
run: go test -v ./... | |
- 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: . | |
file: 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: cosign sign --key ${{ secrets.COSIGN_PRIVATE_KEY }} ${{ secrets.DOCKER_USERNAME }}/hello-world-server:latest |