Skip to content

New release for "213/merge" triggered by lukasz-wal #54

New release for "213/merge" triggered by lukasz-wal

New release for "213/merge" triggered by lukasz-wal #54

name: Release New Version
run-name: New release for "${{ github.ref_name }}" triggered by ${{ github.actor }}
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
workflow_call:
inputs:
version:
required: true
type: string
env:
ECR_REPOSITORY: "filplus-backend"
jobs:
format_and_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
- name: Run Clippy
run: cargo clippy
end_to_end_tests:
runs-on: ubuntu-latest
needs: format_and_lint
environment: staging-fidl
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run tests
env:
GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }}
DB_URL: ${{secrets.DB_URL}}
run: cargo test -- --nocapture
build_and_push:
runs-on: ubuntu-latest
needs: [format_and_lint, end_to_end_tests]
environment: production-fidl
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-build-
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
registry-type: public
- name: Set IMAGE_TAG
run: |
if [ -n "${{ inputs.version }}" ]
then
IMAGE_TAG="${{ inputs.version }}-${{ github.ref_name }}"
else
IMAGE_TAG=$(echo ${{ github.ref_name }} | tr '/' '-')
fi
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build tag and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push tag
if: inputs.version != ''
run: |
TAG_NAME="v${{ env.IMAGE_TAG }}"
git tag $TAG_NAME
git push origin $TAG_NAME