-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
191 additions
and
9 deletions.
There are no files selected for viewing
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Note that the following build needs binaries to be precompiled for the target | ||
# architectures. Use the `build-all` just recipies to build for all targets. | ||
FROM alpine as arm-builder | ||
COPY ./target/armv7-unknown-linux-musleabihf/release/cocogitto_github_app /cocogitto_github_app | ||
|
||
FROM alpine as arm64-builder | ||
COPY ./target/aarch64-unknown-linux-musl/release/cocogitto_github_app /cocogitto_github_app | ||
|
||
FROM alpine as amd64-builder | ||
COPY ./target/x86_64-unknown-linux-musl/release/cocogitto_github_app /cocogitto_github_app | ||
|
||
FROM ${TARGETARCH}-builder AS builder | ||
|
||
FROM alpine | ||
MAINTAINER Paul Delafosse "paul.delafosse@protonmail.com" | ||
|
||
RUN addgroup -S cocogitto && adduser -S cocogitto -G cocogitto | ||
USER cocogitto | ||
|
||
# Install binaries | ||
COPY --from=builder /cocogitto_github_app /usr/bin/cocogitto_github_app | ||
|
||
# Install assets | ||
COPY Rocket.toml . | ||
|
||
EXPOSE 8080 | ||
|
||
COPY ./docker/entrypoint.sh /entrypoint.sh | ||
COPY ./Rocket.toml . | ||
|
||
CMD ["cocogitto_github_app"] | ||
ENTRYPOINT ["/entrypoint.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
exec "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Build | ||
# needed between cross build, otherwise some link to GLIC are broken | ||
clean-targets: | ||
rm -rd target/release | ||
rm target/.rustc_info.json | ||
|
||
build-x86: | ||
cross build --target x86_64-unknown-linux-musl --release | ||
just clean-targets | ||
|
||
build-arm-v7: | ||
cross build --target armv7-unknown-linux-musleabihf --release | ||
just clean-targets | ||
|
||
build-arm-64: | ||
cross build --target aarch64-unknown-linux-musl --release | ||
just clean-targets | ||
|
||
build-all: build-x86 build-arm-v7 build-arm-64 | ||
|
||
docker-build: build-all | ||
docker buildx build --no-cache --push --platform linux/amd64,linux/arm/v7,linux/arm64/v8 . -t oknozor/cocogitto-bot:latest |
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
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