Skip to content

Commit

Permalink
PLAT-546 - moe to shared workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
portswigger-ben committed Sep 2, 2024
1 parent be5039b commit 8ba53ec
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 8 deletions.
62 changes: 54 additions & 8 deletions .github/workflows/build-push-Image.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
name: Build, test and push image

concurrency: ${{ github.ref }}
name: build-push-image

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build-test-image:
uses: portswigger-apps/shared-workflows/.github/workflows/build-test-image.yaml@main
secrets: inherit
with:
setup-go: true
build:
runs-on: ubuntu-latest

steps:
- name: Checkout cod
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build the Go application
run: |
mkdir -p build/linux
cd cmd/moroz
go build -o ../../build/linux/moroz .
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker image
run: docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest .

- name: Trivy Scan
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
exit-code: 1
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL"

- name: Push the Docker image
run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest

62 changes: 62 additions & 0 deletions .github/workflows/image-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# name: Image Release

# on:
# workflow_dispatch: {}
# push:
# branches:
# - main
# tags:
# - "v*"
# pull_request:
# branches:
# - main

# jobs:
# release-continer-image:
# runs-on: ubuntu-latest

# permissions:
# contents: read
# packages: write

# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Set up QEMU (v2.2.0)
# uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7

# - name: Set up Docker Buildx (v2.9.1)
# uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1
# with:
# driver-opts: |
# image=moby/buildkit:v0.12.0

# - name: Login to GHCR (v2.2.0)
# if: ${{ github.event_name != 'pull_request' }}
# uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Docker meta (v4.6.0)
# id: docker-meta
# uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
# with:
# images: |
# ghcr.io/${{ github.repository }}
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}

# - name: Build ARM64/AMD64 Image and push to GHCR (v4.1.1)
# uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
# with:
# context: .
# platforms: linux/amd64,linux/arm64
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.docker-meta.outputs.tags }}
# labels: ${{ steps.docker-meta.outputs.labels }}

0 comments on commit 8ba53ec

Please sign in to comment.