From 46349e0bfa9a0fa4e8b189eef10bec09a59a49a2 Mon Sep 17 00:00:00 2001 From: Nicholas Dille Date: Wed, 15 Nov 2023 20:07:24 +0100 Subject: [PATCH] Added demo --- .github/workflows/build-go.yml | 43 +++++++++++++++++++++++ .github/workflows/check-python.yml | 39 +++++++++++++++++++++ .github/workflows/docker-build.yml | 56 ++++++++++++++++++++++++++++++ go/go.mod | 5 +++ go/go.sum | 2 ++ go/main.go | 15 ++++++++ requirements.txt | 2 ++ ubuntu/22.04/Dockerfile | 24 +++++++++++++ 8 files changed, 186 insertions(+) create mode 100644 .github/workflows/build-go.yml create mode 100644 .github/workflows/check-python.yml create mode 100644 .github/workflows/docker-build.yml create mode 100644 go/go.mod create mode 100644 go/go.sum create mode 100644 go/main.go create mode 100644 requirements.txt create mode 100644 ubuntu/22.04/Dockerfile diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml new file mode 100644 index 0000000..5b11715 --- /dev/null +++ b/.github/workflows/build-go.yml @@ -0,0 +1,43 @@ +name: build-go + +on: + push: + paths: + - "go/*.go" + - "go/go.mod" + - "go/go.sum" + - ".github/workflows/build-go.yml" + pull_request: + types: + - opened + - synchronize + - labeled + - reopened + paths: + - "go/*.go" + - "go/go.mod" + - "go/go.sum" + - ".github/workflows/build-go.yml" + workflow_dispatch: + +permissions: + contents: read + +jobs: + + build-go: + name: build-go + runs-on: ubuntu-22.04 + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build binary + run: | + cd go + go build -o ../hello . + + - name: Smoke test + run: | + ./hello diff --git a/.github/workflows/check-python.yml b/.github/workflows/check-python.yml new file mode 100644 index 0000000..f910aa1 --- /dev/null +++ b/.github/workflows/check-python.yml @@ -0,0 +1,39 @@ +name: check-python + +on: + push: + paths: + - "requirements.txt" + - ".github/workflows/check-python.yml" + pull_request: + types: + - opened + - synchronize + - labeled + - reopened + paths: + - "requirements.txt" + - ".github/workflows/check-python.yml" + workflow_dispatch: + +permissions: + contents: read + +jobs: + + check-python: + name: check-python + runs-on: ubuntu-22.04 + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install + run: | + pip install --requirement requirements.txt + + - name: Smoke test + run: | + cowsay --help + pyfiglet --help diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..bd2dd15 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,56 @@ +name: docker-build + +on: + push: + branches-ignore: + - "renovate/**" + paths: + - "ubuntu/22.04/**" + - ".github/workflows/docker-build.yml" + pull_request: + types: + - opened + - synchronize + - labeled + - reopened + paths: + - "ubuntu/22.04/**" + - ".github/workflows/docker-build.yml" + workflow_dispatch: + +jobs: + build: + name: docker-build + permissions: + packages: write + runs-on: ubuntu-latest + env: + IMAGE_TAG: 22.04 + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + uses: docker/build-push-action@v4 + with: + context: ubuntu/22.04 + platforms: linux/amd64 + provenance: false + sbom: false + cache-from: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} + push: ${{ github.event_name != 'pull_request' }} + tags: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 0000000..d30ae1a --- /dev/null +++ b/go/go.mod @@ -0,0 +1,5 @@ +module github.com/nicholasdille/clc23-renovate-demo + +go 1.20 + +require github.com/TwiN/go-color v1.4.0 diff --git a/go/go.sum b/go/go.sum new file mode 100644 index 0000000..e7a4fb7 --- /dev/null +++ b/go/go.sum @@ -0,0 +1,2 @@ +github.com/TwiN/go-color v1.4.0 h1:fNbOwOrvup5oj934UragnW0B1WKaAkkB85q19Y7h4ng= +github.com/TwiN/go-color v1.4.0/go.mod h1:0QTVEPlu+AoCyTrho7bXbVkrCkVpdQr7YF7PYWEtSxM= diff --git a/go/main.go b/go/main.go new file mode 100644 index 0000000..febfce5 --- /dev/null +++ b/go/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + + "github.com/TwiN/go-color" +) + +var Author string = "unknown" +var Version string = "none" + +func main() { + println(color.InGreen("hello world")) + fmt.Printf("by %s, version %s", Author, Version) +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d84bae2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +cowsay==5.0 +pyfiglet==1.0.1 \ No newline at end of file diff --git a/ubuntu/22.04/Dockerfile b/ubuntu/22.04/Dockerfile new file mode 100644 index 0000000..8741c6c --- /dev/null +++ b/ubuntu/22.04/Dockerfile @@ -0,0 +1,24 @@ +#syntax=docker/dockerfile:1.6.0 + +FROM ubuntu:22.04 AS base + +SHELL [ "bash", "-o", "errexit", "-c"] +ARG DEBIAN_FRONTEND=noninteractive + +COPY </etc/apt/sources.list.d/security.list +apt-get update -o Dir::Etc::SourceList=/etc/apt/false -o Dir::Etc::SourceParts=/etc/apt/sources.list.d +apt-get upgrade -y +rm -f /etc/apt/sources.list.d/security.list +EOF + +ARG ref=main +LABEL org.opencontainers.image.source="https://github.com/nicholasdille/clc23-renovate-demo" \ + org.opencontainers.image.title="Ubuntu" \ + org.opencontainers.image.description="Base image for Ubuntu" \ No newline at end of file