again #21
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: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build_hello-world: | |
defaults: | |
run: | |
working-directory: rust/hello-world | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Install rustup parts | |
run: rustup toolchain install stable-aarch64-unknown-linux-gnu | |
- name: Lint | |
run: | | |
cargo fmt -- --check | |
cargo clippy -- -D warnings | |
- name: Test | |
run: | | |
cargo check | |
cargo test --all | |
- name: Build release | |
run: cargo build --release --target aarch64-unknown-linux-gnu | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hello-world | |
path: | | |
rust/hello-world/target/release/hello-world | |
- name: Log into ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/babdor/curly-meme | |
- name: Get binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: hello-world | |
path: ./ | |
- name: Build and push to ghcr | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
tags: ${{ env.REGISTRY }}/babdor/curly-meme:latest | |
labels: ${{ steps.meta.outputs.labels }} |