Dockerize application and add CI #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v*.*.*" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
toolchain: | |
- 1.78.0 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | |
- run: cargo build --verbose | |
- run: cargo test --verbose -- --skip util::geo_ip::tests::test_get_country_code | |
docker: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
# See https://web.archive.org/web/20240729104252/https://docs.docker.com/build/ci/github-actions/manage-tags-labels/ | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/Bastian/bstats-data-processor/bstats-data-processor | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
# See https://web.archive.org/web/20240709084932/https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 #,linux/arm64 (arm disabled because it takes forever) | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |