Skip to content

Commit

Permalink
chore: setup github action
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-segning committed Aug 13, 2024
1 parent 7bf0572 commit 67e5e21
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Translator

on:
push:
branches:
- '**'
tags-ignore:
- 'v*'
paths:
- '**'

env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
IMAGE_NAME: ADORSYS-GIS/wazuh-cert-oauth2

jobs:
build:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

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

- name: Build Translator
run: cargo build --verbose && cargo test --verbose

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

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

- name: Login to the Docker registry
id: login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lowercase
name: Lowercase image name
uses: AsZc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_NAME }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.lowercase.outputs.lowercase }}
tags: |
type=raw,value=latest
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push Docker image
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
push: "${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust as base

WORKDIR /app

FROM base as builder

# Copy the Cargo.toml and Cargo.lock files to cache dependencies
COPY ./ ./

# Build the dependencies
RUN cargo build --release

FROM base

WORKDIR /app

COPY --from=builder /app/target/release/wazuh-cert-oauth2 /app/wazuh-cert-oauth2

CMD ["/app/wazuh-cert-oauth2"]

0 comments on commit 67e5e21

Please sign in to comment.