From a688e695a584ff4c1996838db9b778a197f0bf30 Mon Sep 17 00:00:00 2001 From: mrasheduzzaman Date: Sun, 19 Nov 2023 15:56:23 +0600 Subject: [PATCH] Add docker image build and deploy workflow --- .github/workflows/cd.yml | 51 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..67bb19e --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,51 @@ +name: CD + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a288eb..4e2b9c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ name: CI -on: [push] +on: [pull_request] jobs: audit: runs-on: ubuntu-latest