Skip to content

Commit

Permalink
Move deployment to github actions and publish to GHCR (#4)
Browse files Browse the repository at this point in the history
This PR migrates the `deploy.sh` script to a GitHub action like we did for cowprotocol/services#2.

I also noticed that this repo does not auto-redeploy on new commits like we have in the services repo. I will leave it as-is if this is intended. If not we can use cowprotocol/autodeploy-action to trigger a re-deploy of the pods on new commits.

I also fixed some small `cargo clippy` lints to make CI pass.

Build a docker image when this merges!
  • Loading branch information
Nicholas Rodrigues Lordello committed Apr 7, 2022
1 parent 33bd606 commit 7594200
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 28 deletions.
50 changes: 44 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,51 @@ on:
push:
branches: [main, main_alpha]
tags: [v*]

jobs:
deploy:
runs-on: ubuntu-latest
env:
DOCKERHUB_PROJECT: gp-data
DOCKER_NAME: ${{ secrets.DOCKER_NAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- run: docker/deploy.sh ${GITHUB_REF#refs/*/}
- uses: actions/checkout@v3

- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: API image metadata
id: meta_api
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}-api
labels: |
org.opencontainers.image.licenses=MIT OR Apache-2.0
- name: API image build
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile.binary
push: true
tags: ${{ steps.meta_api.outputs.tags }}
labels: ${{ steps.meta_api.outputs.labels }}

- name: Fetcher image metadata
id: meta_fecher
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}-fetcher
labels: |
org.opencontainers.image.licenses=MIT OR Apache-2.0
- name: Fetcher image build
uses: docker/build-push-action@v2
with:
context: dune_api_scripts
file: dune_api_scripts/docker/Dockerfile.binary
push: true
tags: ${{ steps.meta_fecher.outputs.tags }}
labels: ${{ steps.meta_fecher.outputs.labels }}
15 changes: 0 additions & 15 deletions docker/deploy.sh

This file was deleted.

9 changes: 4 additions & 5 deletions src/dune_data_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ pub fn load_data_from_json_into_memory(
) -> DateTime<Utc> {
for user_data in dune_download.user_data {
let address: H160 = user_data.data.owner;
let vector_to_insert;
if let Some(data_vector) = memory_database.get_mut(&address) {
let vector_to_insert = if let Some(data_vector) = memory_database.get_mut(&address) {
data_vector.push(user_data.data);
vector_to_insert = data_vector.to_vec();
data_vector.to_vec()
} else {
vector_to_insert = vec![user_data.data];
}
vec![user_data.data]
};
memory_database.insert(address, vector_to_insert);
}
dune_download.time_of_download
Expand Down
3 changes: 1 addition & 2 deletions src/models/in_memory_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ impl InMemoryDatabase {
total_referrals: {
let mut vec_referrals: Vec<H160> = data
.iter()
.map(|data| data.referrals.clone())
.flatten()
.flat_map(|data| data.referrals.clone())
.collect();
let set: HashSet<_> = vec_referrals.drain(..).collect();
set.len() as u64
Expand Down

0 comments on commit 7594200

Please sign in to comment.