diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index cdfc2a0..ad98f8c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -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/*/} \ No newline at end of file + - 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 }} diff --git a/docker/deploy.sh b/docker/deploy.sh deleted file mode 100755 index d9a54bc..0000000 --- a/docker/deploy.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_NAME" --password-stdin -# Build and tag api-image -docker build -t "${DOCKERHUB_PROJECT}" -f docker/Dockerfile.binary . -docker tag "${DOCKERHUB_PROJECT}" gnosispm/"${DOCKERHUB_PROJECT}":$1 -docker push gnosispm/"${DOCKERHUB_PROJECT}":$1 - -# Build and tag dune-data-fetcher-image -cd dune_api_scripts -docker build -t "${DOCKERHUB_PROJECT}-fetcher" -f docker/Dockerfile.binary . -docker tag "${DOCKERHUB_PROJECT}-fetcher" gnosispm/"${DOCKERHUB_PROJECT}-fetcher":$1 -docker push gnosispm/"${DOCKERHUB_PROJECT}-fetcher":$1 \ No newline at end of file diff --git a/src/dune_data_loading.rs b/src/dune_data_loading.rs index f57ee8d..99043f2 100644 --- a/src/dune_data_loading.rs +++ b/src/dune_data_loading.rs @@ -40,13 +40,12 @@ pub fn load_data_from_json_into_memory( ) -> DateTime { 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 diff --git a/src/models/in_memory_database.rs b/src/models/in_memory_database.rs index 7a974d8..f00341b 100644 --- a/src/models/in_memory_database.rs +++ b/src/models/in_memory_database.rs @@ -51,8 +51,7 @@ impl InMemoryDatabase { total_referrals: { let mut vec_referrals: Vec = 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