Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github pipelines #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/push-to-ecr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Push to Amazon ECR

on: workflow_dispatch

env:
AWS_REGION: ${{ vars.AWS_REGION }} # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} # set this to your Amazon ECR repository name

jobs:
push-deploy:
name: Push and Deploy
runs-on: ubuntu-latest
environment: dev

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
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@62f4f872db3836360b72999f4b87f1ff13310f3a

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile-demo .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
57 changes: 57 additions & 0 deletions .github/workflows/run-tx-tool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Run tx-tool from ECR

on:
workflow_dispatch:
inputs:
zcash_node_address:
description: "Zcash node address"
required: false
default: "127.0.0.1"
zcash_node_port:
description: "Zcash node port"
required: false
default: "18232"
zcash_node_protocol:
description: "Zcash node protocol"
required: false
default: "http"

env:
AWS_REGION: ${{ vars.AWS_REGION }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}

jobs:
run-container:
name: Run Container from ECR
runs-on: ubuntu-latest
environment: dev

steps:
- 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: Pull Docker image from ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Run Docker container
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
docker run \
-e ZCASH_NODE_ADDRESS="${{ github.event.inputs.zcash_node_address }}" \
-e ZCASH_NODE_PORT="${{ github.event.inputs.zcash_node_port }}" \
-e ZCASH_NODE_PROTOCOL="${{ github.event.inputs.zcash_node_protocol }}" \
$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
4 changes: 2 additions & 2 deletions Dockerfile-demo
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ RUN wget https://dist.ipfs.io/go-ipfs/v0.9.1/go-ipfs_v0.9.1_linux-amd64.tar.gz &
rm -rf go-ipfs go-ipfs_v0.9.1_linux-amd64.tar.gz

# Make fetch-params.sh executable
RUN chmod +x fetch-params.sh
RUN chmod +x ./zcutil/fetch-params.sh

# Run fetch-params.sh
RUN ./fetch-params.sh
RUN ./zcutil/fetch-params.sh

# Create necessary directories
RUN mkdir -p /root/.local/share/ZcashParams
Expand Down
22 changes: 15 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,22 @@ pub struct NetworkConfig {

impl Default for NetworkConfig {
fn default() -> Self {
let node_address = env::var("ZCASH_NODE_ADDRESS").unwrap_or_else(|_| "127.0.0.1".to_string());
let node_port = env::var("ZCASH_NODE_PORT")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(18232);
let protocol = env::var("ZCASH_NODE_PROTOCOL").unwrap_or_else(|_| "http".to_string());

println!(
"Using NetworkConfig: node_address = {}, node_port = {}, protocol = {}",
node_address, node_port, protocol
);

Self {
node_address: env::var("ZCASH_NODE_ADDRESS")
.unwrap_or_else(|_| "127.0.0.1".to_string()),
node_port: env::var("ZCASH_NODE_PORT")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(18232),
protocol: env::var("ZCASH_NODE_PROTOCOL").unwrap_or_else(|_| "http".to_string()),
node_address,
node_port,
protocol,
}
}
}
Expand Down
Loading