Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test buildx vs docker for cloudsmith uploads #427

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/test-build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: buildx
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest-8cpu
permissions:
contents: read # required for checkout
id-token: write # mint credentials through OIDC
packages: write

strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile
image_name: aws-source

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 Cloudsmith Container Registry
uses: docker/login-action@v3
with:
registry: docker.cloudsmith.io
username: ${{ secrets.CLOUDSMITH_SERVICE_USER }}
password: ${{ secrets.CLOUDSMITH_API_KEY }}

- name: Build and push
id: push
uses: docker/build-push-action@v5
with:
file: build/package/${{ matrix.dockerfile }}
context: .
sbom: true
platforms: linux/amd64,linux/arm64
push: true
tags: docker.cloudsmith.io/overmind/service/${{ matrix.image_name }}:buildx
77 changes: 7 additions & 70 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Test & Build
name: depot
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
Expand All @@ -14,50 +14,9 @@ on:
workflow_dispatch:

jobs:
test:
name: Test
runs-on: depot-ubuntu-22.04-8

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.x
check-latest: true

- name: Get dependencies
run: |
go get -v -t -d ./...

- name: Validate Docs Data
run: |
mkdir -p ~/.local/bin/ && curl -Lo ~/.local/bin/docgen https://github.com/overmindtech/docgen/releases/latest/download/docgen-amd64 && chmod +x ~/.local/bin/docgen
go generate ./...
if [ -z "$(git status --porcelain)" ]; then
echo "No pending docs changes"
else
echo "Pending docs changes found, please run 'go generate ./...' and commit the changes"
git status
exit 1
fi

- name: Vet
run: go vet

- name: Run tests
run: go test -race -v ./...
env:
# Environment variables so that AWS resources can be created
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-2

build:
name: Build
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
needs:
- test
permissions:
contents: read # required for checkout
id-token: write # mint credentials through OIDC
Expand All @@ -74,23 +33,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/overmindtech/${{ matrix.image_name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Login to GitHub Container Registry
- name: Login to Cloudsmith Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.cloudsmith.io
username: ${{ secrets.CLOUDSMITH_SERVICE_USER }}
password: ${{ secrets.CLOUDSMITH_API_KEY }}

- uses: depot/setup-action@v1

Expand All @@ -103,16 +51,5 @@ jobs:
context: .
sbom: true
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Prepare Deployment
run: |
echo "ghcr.io/overmindtech/${{ matrix.image_name }}@${{ steps.push.outputs.digest }}" | tee ${{ matrix.image_name }}.imageref

- name: Upload Deployment File
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.image_name }}.imageref
path: ${{ matrix.image_name }}.imageref
push: true
tags: docker.cloudsmith.io/overmind/service/${{ matrix.image_name }}:depot