Skip to content

Commit

Permalink
Merge pull request #24 from duyet/feat/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
duyet committed Mar 20, 2022
2 parents 30411d8 + a7e1990 commit 3277554
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: Build & Test

on:
schedule:
- cron: "0 10 * * *"
push:
branches: [master]
branches:
- master
tags:
- "v*.*.*"
pull_request:
branches: [master]
branches:
- master

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -47,6 +53,23 @@ jobs:
- name: Rust tests
run: TEST_DATABASE_URL=postgres://postgres:postgres@localhost cargo test --verbose

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/duyet/glossary
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -64,10 +87,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/duyet/glossary:latest
ghcr.io/duyet/glossary:0.1.0
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
7 changes: 0 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ FROM rust:1-buster AS builder
RUN update-ca-certificates
WORKDIR /app

# Download crates-io index and fetch dependency code.
# This step avoids needing to spend time on every build downloading the index
# which can take a long time within the docker context. Docker will cache it.
RUN USER=root cargo init
COPY Cargo.toml Cargo.toml
RUN cargo fetch

# Copy and compile
COPY . .
RUN cargo build --release
Expand Down

0 comments on commit 3277554

Please sign in to comment.