Skip to content

Update libs

Update libs #157

Workflow file for this run

name: Build and push
on:
push:
branches: [main, '**']
paths:
- '**'
- '!charts/**'
tags:
- '**'
- '!helm-*'
pull_request:
branches: [main]
paths:
- '**'
- '!charts/**'
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$PATH:$HOME/.cargo/bin"
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install Checks
run: |
cargo install cargo-deny || true
cargo install cargo-outdated || true
cargo install cargo-audit || true
cargo install cargo-pants || true
- name: Format
run: |
cargo fmt --all -- --check
- name: Clippy
run: |
cargo clippy -- -D warnings
- name: Test
run: cargo test
- name: Deny
run: |
cargo deny check
- name: Outdated
run: |
cargo outdated --exit-code 1 -d 1
- name: Audit
run: |
rm -rf ~/.cargo/advisory-db
cargo audit
- name: Pants
run: |
cargo pants --ignore-file .pants-ignore
#push on commit to main
push_docker:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || ( startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-') )
needs: check
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Get short SHA
if: github.ref == 'refs/heads/main'
id: get_short_sha
run: echo ::set-output name=SHA::$(echo ${GITHUB_SHA} | cut -c1-7)
- name: Get the version
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to ECR
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
- name: Change version in Cargo.toml
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
run: |
sed -i "0,/version = .*/s/version = .*/version = \"${{ steps.get_version.outputs.VERSION }}\"/g" Cargo.toml
- name: Build and push Dev
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
cache-from: type=registry,ref=ghcr.io/kyotu-technology/${{ github.event.repository.name }}:buildcache
cache-to: type=registry,ref=ghcr.io/kyotu-technology/${{ github.event.repository.name }}:buildcache,mode=max
push: true
tags: |
${{ secrets.REGISTRY_URL }}/${{ github.event.repository.name }}:dev-${{ steps.get_short_sha.outputs.SHA }}
- name: Build and push Production
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
cache-from: type=registry,ref=ghcr.io/kyotu-technology/${{ github.event.repository.name }}:buildcache
cache-to: type=registry,ref=ghcr.io/kyotu-technology/${{ github.event.repository.name }}:buildcache,mode=max
push: true
tags: |
${{ secrets.REGISTRY_URL }}/${{ github.event.repository.name }}:${{ steps.get_version.outputs.VERSION }}
${{ secrets.REGISTRY_URL }}/${{ github.event.repository.name }}:latest
- name: Change App version in Helm Chart
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
run: |
sed -i "s/appVersion: .*/appVersion: ${{ steps.get_version.outputs.VERSION }}/g" charts/kyotu-project-operator/Chart.yaml
- name: Push back to repo
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add charts/kyotu-project-operator/Chart.yaml
git add Cargo.toml
git commit -m "Update Chart.yaml appVersion to ${{ steps.get_version.outputs.VERSION }}"
- name: Push back to GitHub
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/helm-')
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true