Skip to content

Commit

Permalink
Add GitHub CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Thadah committed Nov 23, 2024
1 parent 2ee2ed8 commit a3185c4
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI/CD Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build_and_push:
runs-on: ubuntu-latest

steps:
# 1. Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# 2. Set up Rust toolchain
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true

# 3. Install necessary system dependencies
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev build-essential curl tar
# 4. Install Binaryen
- name: Install Binaryen
env:
BINARYEN_VERSION: 120_b
run: |
curl -L -o binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/version_${{ env.BINARYEN_VERSION }}/binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz
tar -xzf binaryen.tar.gz
sudo mv binaryen-version_${BINARYEN_VERSION} /opt/binaryen
sudo ln -s /opt/binaryen/bin/wasm-opt /usr/local/bin/wasm-opt
rm binaryen.tar.gz
# 5. Install trunk
- name: Install trunk
run: cargo install --locked trunk

# 6. Build the project
- name: Build project
run: trunk build --release --dist=dist

# 7. Run tests (if any)
- name: Run Tests
run: cargo test --release

# 8. Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# 9. Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# 10. Build and push the Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: thadah/v_vmifier:latest

0 comments on commit a3185c4

Please sign in to comment.