-
Notifications
You must be signed in to change notification settings - Fork 7
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
182 changed files
with
37,432 additions
and
6,746 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,126 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
env: | ||
AWS_REGION: us-east-2 # set this to your preferred AWS region, e.g. us-west-1 | ||
ECR_REPOSITORY: ferrum_node | ||
|
||
jobs: | ||
run_test: | ||
name: 'Run Rust tests' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Rust Setup | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly-2023-01-26 | ||
target: wasm32-unknown-unknown | ||
override: true | ||
- name: Install protoc | ||
uses: arduino/setup-protoc@v1 | ||
- name: Run tests | ||
run: | | ||
cargo install cargo-expand && | ||
TRYBUILD=overwrite cargo test --locked --verbose --all | ||
build: | ||
name: 'Build docker image and push to ECR' | ||
needs: run_test | ||
# if: steps.run_test.outcome == 'success' | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and | ||
# push it to ECR so that it can | ||
# be deployed to ECS. | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/ferrum.Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
- name: Build and push to DockerHub | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
|
||
deploy: | ||
name: 'EC2 Deployment' | ||
needs: build | ||
# if: steps.build.outcome == 'success' | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Deploy to ec2 server | ||
uses: appleboy/ssh-action@v0.1.8 | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | ||
port: 22 | ||
script: sudo /usr/local/bin/deployment.sh > /var/log/scripts/deployments.log 2>&1 | ||
|
||
lint: | ||
name: 'Run lints' | ||
needs: run_test | ||
# if: steps.run_test.outcome == 'success' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Rust Setup | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly-2022-10-10 | ||
target: wasm32-unknown-unknown | ||
override: true | ||
components: rustfmt, clippy | ||
- name: Install protoc | ||
uses: arduino/setup-protoc@v1 | ||
- name: Check Cargo.toml Format | ||
run: | | ||
if taplo --version &> /dev/null; then | ||
echo "taplo-cli is already installed" | ||
else | ||
cargo install taplo-cli | ||
fi | ||
taplo fmt --check | ||
- name: Rustfmt | ||
run: cargo fmt --all -- --check |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.