Skip to content

Commit

Permalink
feat: add docker build and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Aug 1, 2023
1 parent 38a92b2 commit c36f920
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 74 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lints:
name: Format & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: clippy
args: -- -D warnings

- uses: Swatinem/rust-cache@v1

arch-matrix:
needs: [lints, test]
runs-on: ubuntu-latest
env:
CROSS_CONFIG: Cross.toml
strategy:
matrix:
target: [ "armv7-unknown-linux-musleabihf", "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl" ]
steps:
- name: Checkout sources
uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
target: ${{ matrix.target }}

- name: Cargo build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release

- uses: actions/upload-artifact@master
with:
name: ${{ matrix.target }}
path: ./target/${{ matrix.target }}/release/cocogitto_github_app

docker-build:
name: Update docker multi-arch latest
needs: [ arch-matrix ]
runs-on: ubuntu-latest
steps:
- name: Install docker buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: Docker Hub login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout sources
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
path: ~/artifacts

- name: Copy artifacts to build dir
run: |
mkdir -p target/x86_64-unknown-linux-musl/release/
mkdir -p target/aarch64-unknown-linux-musl/release/
mkdir -p target/armv7-unknown-linux-musleabihf/release/
cp -r ~/artifacts/aarch64-unknown-linux-musl/* target/aarch64-unknown-linux-musl/release/
cp -r ~/artifacts/armv7-unknown-linux-musleabihf/* target/armv7-unknown-linux-musleabihf/release/
cp -r ~/artifacts/x86_64-unknown-linux-musl/* target/x86_64-unknown-linux-musl/release/
chmod +x -R target/aarch64-unknown-linux-musl/release
chmod +x -R target/armv7-unknown-linux-musleabihf/release
chmod +x -R target/x86_64-unknown-linux-musl/release
working-directory: ./

- name: Update multi-arch container latest
run: |
docker buildx build \
--push --platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
. -t oknozor/cocogitto_github_app:latest
96 changes: 39 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c36f920

Please sign in to comment.