Skip to content

Commit

Permalink
feat(ci/cd): update gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
uhryniuk committed Oct 7, 2024
1 parent 45b4447 commit 54d9599
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Push Docker Image

on:
workflow_run:
workflows: ["Rust lint, build and test"]
types:
- completed

jobs:
build-and-push:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Extract version
id: cargo-version
run: |
VERSION=$(grep '^version' Cargo.toml | head -n 1 | awk -F'"' '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version extracted: $VERSION"
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build image
run: docker build -t docker.io/uhryniuk/tally:${{ env.VERSION }} .

- name: Push image
run: docker push docker.io/uhryniuk/tally:${{ env.VERSION }}

11 changes: 1 addition & 10 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: Rust lint, build and test

on:
push:
Expand All @@ -14,45 +14,36 @@ jobs:
runs-on: ubuntu-latest

steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v3

# Install a specific version of Rust (e.g., 1.68.0)
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

# Install rustfmt, clippy, and other components
- name: Install rustfmt, clippy, and audit
run: |
rustup component add rustfmt clippy
cargo install cargo-audit
# Run rustfmt to check code formatting
- name: Check formatting with rustfmt
run: cargo fmt -- --check

# Run clippy to check for linting issues
- name: Run Clippy for linting
run: cargo clippy -- -D warnings

# Run cargo audit to check for security vulnerabilities
- name: Run cargo audit for security vulnerabilities
run: cargo audit

# Build the project
- name: Build project
run: cargo build --release

# Run the tests
- name: Run tests
run: cargo test

# Check if version has been incremented
- name: Ensure version has been incremented
run: |
VERSION_BASE=$(git show origin/main:Cargo.toml | grep '^version = ' | awk '{ print $3 }' | tr -d '"')
Expand Down

0 comments on commit 54d9599

Please sign in to comment.