Skip to content

Commit

Permalink
update actions configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikks committed Feb 8, 2025
1 parent 9866d65 commit b328ea4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 35 deletions.
39 changes: 17 additions & 22 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ jobs:
compile-frontend:
name: Compile frontend
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: npm ci
Expand All @@ -23,27 +26,27 @@ jobs:
working-directory: frontend

- name: Archive binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: frontend
path: frontend/dist/discord-soundboard-bot/**

docker:
name: Build docker image
needs: [compile-frontend]
needs: [ compile-frontend ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Download frontend
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: frontend
path: frontend/dist/discord-soundboard-bot/

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/dominikks/discord-soundboard-bot

Expand All @@ -54,35 +57,27 @@ jobs:
echo "BUILD_ID=${GITHUB_REF#refs/heads/}#$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

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

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TIMESTAMP
BUILD_ID
20 changes: 8 additions & 12 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: npm ci
Expand All @@ -31,22 +33,16 @@ jobs:
name: Lint backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- name: Run formatter
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path backend/Cargo.toml --check
run: cargo fmt --manifest-path backend/Cargo.toml --check

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path backend/Cargo.toml
run: cargo clippy --manifest-path backend/Cargo.toml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN addgroup --gid 1000 discordbot \
&& chown -R discordbot:discordbot /app

COPY --chown=discordbot:discordbot --from=builder /app/target/x86_64-unknown-linux-musl/release/discord-soundboard-bot /app/Rocket.toml /app/
ADD --chown=discordbot:discordbot frontend/dist/discord-soundboard-bot /app/static
ADD --chown=discordbot:discordbot frontend/dist/discord-soundboard-bot/browser frontend/dist/discord-soundboard-bot/3rdpartylicenses.txt /app/static/

############################################################
### Stage 3: Final image
Expand Down

0 comments on commit b328ea4

Please sign in to comment.