Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
73 changes: 73 additions & 0 deletions .github/workflows/build-and-push-image.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can separate it to two workflows: one for ci, and one for image build&push (and add manual dispatch there)

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Docker Image Build
on:
push:
tags:
- v*
pull_request:
branches: ["main"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8
with:
toolchain: nightly-2024-10-17
components: rustfmt, clippy

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy -- -D warnings

build-and-push:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871

# Set image tag to git tag, or commit hash for pull request
- name: Set IMAGE_TAG
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
fi

- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.IMAGE_TAG }}
type=raw,value=${{ github.sha }}
type=raw,value=latest

- name: Build and push Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# any config files
config.yaml

# MacOS config file
.DS_Store

# env files
*.env

**/target/
**/out/
**/lib/
**/cache/
**/broadcast/
node_modules
.idea
Loading