From 5a5e53c59105c7b289238393721affc6a37068a6 Mon Sep 17 00:00:00 2001 From: penumbra23 Date: Thu, 27 Jul 2023 11:30:18 +0200 Subject: [PATCH] Add tags for Docker images --- .github/workflows/release.yaml | 37 +++++++++++++++++++++++----------- build_connectors.sh | 8 ++++---- push_connectors.sh | 28 +++++++++++++++++++++---- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 46149b77..fbfd5036 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,13 +1,31 @@ on: - release: - types: - - created + push: + branches: + - master name: deploy jobs: + set-tags: + name: Get & set tags + runs-on: ubuntu-latest + outputs: + commit_hash: ${{ steps.get-sha.outputs.sha }} + commit_hash8: ${{ steps.get-sha.outputs.sha8 }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Get commit SHA + id: get-sha + run: | + sha=$(git log -1 --format='%H') + echo "sha=$sha" >> $GITHUB_OUTPUT + echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT + echo "SHA commit:" $sha + deploy: runs-on: ubuntu-latest + needs: ["set-tags"] steps: - name: Login to Docker Hub uses: docker/login-action@v2 @@ -27,13 +45,8 @@ jobs: with: targets: x86_64-unknown-linux-musl - - run: ./build_connectors.sh - - run: ./push_connectors.sh + - name: Build connector Docker images + run: ./build_connectors.sh - #- uses: withlogicco/setup-compose-cli@v1 - #- run: docker context create ecs aws --from-env - #- run: docker --context=aws compose up - # env: - # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + - name: Push connector images to Dockerhub + run: ./push_connectors.sh ${{ needs.set-tags.outputs.commit_hash8 }} diff --git a/build_connectors.sh b/build_connectors.sh index 99abbd1f..9876f29d 100755 --- a/build_connectors.sh +++ b/build_connectors.sh @@ -2,19 +2,19 @@ cargo build -p rosetta-server-bitcoin --target x86_64-unknown-linux-musl --release mkdir -p target/release/bitcoin/bin cp target/x86_64-unknown-linux-musl/release/rosetta-server-bitcoin target/release/bitcoin/bin -docker build target/release/bitcoin -f chains/bitcoin/Dockerfile -t analoglabs/connector-bitcoin +docker build target/release/bitcoin -f chains/bitcoin/Dockerfile -t analoglabs/connector-bitcoin:latest cargo build -p rosetta-server-ethereum --target x86_64-unknown-linux-musl --release mkdir -p target/release/ethereum/bin cp target/x86_64-unknown-linux-musl/release/rosetta-server-ethereum target/release/ethereum/bin -docker build target/release/ethereum -f chains/ethereum/Dockerfile -t analoglabs/connector-ethereum +docker build target/release/ethereum -f chains/ethereum/Dockerfile -t analoglabs/connector-ethereum:latest cargo build -p rosetta-server-polkadot --target x86_64-unknown-linux-musl --release mkdir -p target/release/polkadot/bin cp target/x86_64-unknown-linux-musl/release/rosetta-server-polkadot target/release/polkadot/bin -docker build target/release/polkadot -f chains/polkadot/Dockerfile -t analoglabs/connector-polkadot +docker build target/release/polkadot -f chains/polkadot/Dockerfile -t analoglabs/connector-polkadot:latest cargo build -p rosetta-server-astar --target x86_64-unknown-linux-musl --release mkdir -p target/release/astar/bin cp target/x86_64-unknown-linux-musl/release/rosetta-server-astar target/release/astar/bin -docker build target/release/astar -f chains/astar/Dockerfile -t analoglabs/connector-astar +docker build target/release/astar -f chains/astar/Dockerfile -t analoglabs/connector-astar:latest diff --git a/push_connectors.sh b/push_connectors.sh index 09c45019..4d1bc342 100755 --- a/push_connectors.sh +++ b/push_connectors.sh @@ -1,5 +1,25 @@ #!/bin/sh -docker push analoglabs/connector-bitcoin -docker push analoglabs/connector-ethereum -docker push analoglabs/connector-polkadot -docker push analoglabs/connector-astar \ No newline at end of file + +# First arg is the Docker image tag on all images +tag=$1 + +docker push analoglabs/connector-bitcoin:latest +docker push analoglabs/connector-ethereum:latest +docker push analoglabs/connector-polkadot:latest +docker push analoglabs/connector-astar:latest + +if [ ! -z "$tag" ]; then + echo "Tagging all images: $tag"; + docker tag analoglabs/connector-bitcoin analoglabs/connector-bitcoin:$tag + docker push analoglabs/connector-bitcoin:$tag + + docker tag analoglabs/connector-ethereum analoglabs/connector-ethereum:$tag + docker push analoglabs/connector-ethereum:$tag + + docker tag analoglabs/connector-polkadot analoglabs/connector-polkadot:$tag + docker push analoglabs/connector-polkadot:$tag + + docker tag analoglabs/connector-astar analoglabs/connector-astar:$tag + docker push analoglabs/connector-astar:$tag +fi +