Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
2xburnt committed Oct 2, 2024
1 parent 8eedec1 commit 3823a9a
Show file tree
Hide file tree
Showing 4 changed files with 405 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build Docker Images

# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:

env:
repo_names: |
ghcr.io/${{ github.repository }}
jobs:
build-images:
name: Build ${{ matrix.os }}/${{ matrix.arch }}
runs-on: ${{ format('burnt-labs-{0}', matrix.arch) }}

strategy:
fail-fast: false
matrix:
os:
- linux
arch:
- amd64
- arm64

permissions:
id-token: write
contents: read
packages: write

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up docker buildx for push
uses: docker/setup-buildx-action@v3
with:
driver: docker
platforms: ${{ matrix.os }}/${{ matrix.arch }}

- name: Prepare environment
run: |
echo "TAG_VERSION=${GITHUB_SHA:0:7}" | tee -a $GITHUB_ENV
echo "CONTAINER=$(basename $(echo ${{ env.repo_names }} | head -n1 ))" | tee -a $GITHUB_ENV
echo "DOCKER_FN=$CONTAINER-${{ matrix.os }}-${{ matrix.arch }}.tar" | tee -a $GITHUB_ENV
- name: Metadata for container
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.repo_names }}
tags: |
type=sha
- name: Build Docker Image
id: build-docker
uses: docker/build-push-action@v5
with:
target: release
push: false
load: true
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}
tags: ${{ steps.meta.outputs.tags }}

- name: Save Docker Image
working-directory: ${{ runner.temp }}
run: |
docker save ${{ steps.meta.outputs.tags }} > ${{ runner.temp }}/${DOCKER_FN}
- name: Upload Docker Image
uses: actions/upload-artifact@v4
with:
name: ${{ env.DOCKER_FN }}
path: ${{ runner.temp }}/${{ env.DOCKER_FN }}
if-no-files-found: error
retention-days: 3
97 changes: 97 additions & 0 deletions .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Push Docker images

# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:

env:
REPOS: |
burntnetwork/xion
ghcr.io/${{ github.repository }}/xion
385156030167.dkr.ecr.us-east-1.amazonaws.com/burnt/xiond
jobs:
merge:
name: Create registry manifests
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Prepare environment
run: |
echo "TAG_VERSION=${GITHUB_SHA:0:7}" | tee -a $GITHUB_ENV
- name: Metadata for xion container
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REPOS }}
tags: |
type=raw,value=${{ env.TAG_VERSION }}
type=semver,pattern={{version}},enable=${{ github.event_name == 'push' }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Download images
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}
pattern: docker*
merge-multiple: true

- name: Load images
working-directory: ${{ runner.temp }}
run: |
for image in docker*.tar; do
PLATFORM=$(basename $image .tar | cut -d- -f2-)
docker load < $image;
docker tag xion:$PLATFORM burntnetwork/xion:$PLATFORM
docker push burntnetwork/xion:$PLATFORM;
done;
- name: Prepare mainfest vars
run: |
IMAGE_TARGETS=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< $DOCKER_METADATA_OUTPUT_JSON)
IMAGE_TAGS=$(docker image ls burntnetwork/xion --digests --format json | jq -r '"\(.Repository):\(.Tag)"' | tr '\n' ' ')
echo "IMAGE_TAGS=$IMAGE_TAGS" | tee -a $GITHUB_ENV
echo "IMAGE_TARGETS=${IMAGE_TARGETS}" | tee -a $GITHUB_ENV
- name: Create manifest list and push
run: |
eval "docker buildx imagetools create ${IMAGE_TARGETS} ${IMAGE_TAGS}"
- name: Inspect image
run: |
jq -cr '.tags | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON" | \
xargs -n1 docker buildx imagetools inspect%
51 changes: 51 additions & 0 deletions .github/workflows/docker-scout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Scout

# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:

jobs:
docker-scout:
name: main
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

strategy:
fail-fast: false
matrix:
os:
- linux
arch:
- amd64
- arm64

steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Download images
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}
pattern: docker-${{ matrix.os }}-${{ matrix.arch }}.tar
merge-multiple: true

- name: Load images
working-directory: ${{ runner.temp }}
run: |
ls -la
docker load < ${{ env.DOCKER_FN }}
- name: Run Docker Scout
uses: docker/scout-action@v1
with:
command: cves
only-fixed: true
platform: ${{ matrix.os }}/${{ matrix.arch }}
image: xion:${{ matrix.os }}-${{ matrix.arch }}
Loading

0 comments on commit 3823a9a

Please sign in to comment.