From 2a285064d897c73228f3e34616b28684d8c7708a Mon Sep 17 00:00:00 2001 From: Willem Olding Date: Mon, 15 Apr 2024 13:42:49 +1000 Subject: [PATCH] add example workflow to publish docker images --- .github/workflows/docker.yml | 56 +++++++++++++++++++ .../workflows/{fly.yml => fly.yml.scratch} | 14 +++-- fly.fullnode.toml | 2 +- fly.toml | 2 +- 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/docker.yml rename .github/workflows/{fly.yml => fly.yml.scratch} (76%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6baf9a5 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,56 @@ +name: Publish Docker images + +on: + release: + types: [published] + +jobs: + push_fullnode_to_registry: + name: Push fullnode Docker image to fly.io + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: 🔑 Fly Registry Auth + uses: docker/login-action@v1 + with: + registry: registry.fly.io + username: x + password: ${{ secrets.FLY_API_TOKEN }} + + - name: 🐳 Docker build (fullnode) + uses: docker/build-push-action@v2 + with: + context: . + file: ./fullnode.Dockerfile + push: true + tags: registry.fly.io/cartezcash-fullnode:latest + build-args: | + COMMIT_SHA=${{ github.sha }} + + push_cartesi_node_to_registry: + name: Push cartesi node Docker image to fly.io + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: 🔑 Fly Registry Auth + uses: docker/login-action@v1 + with: + registry: registry.fly.io + username: x + password: ${{ secrets.FLY_API_TOKEN }} + + - name: Setup Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + + - name: Install Sunodo and build + run: | + npm install -g @sunodo/cli + IMAGE_TAG=$(sunodo deploy build --platform linux/amd64 | grep "Application node Docker image" | awk '{print $NF}') + docker push $IMAGE_TAG:registry.fly.io/cartezcash:latest diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml.scratch similarity index 76% rename from .github/workflows/fly.yml rename to .github/workflows/fly.yml.scratch index 5af8976..772617a 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml.scratch @@ -1,11 +1,15 @@ -name: Fly Deploy +name: Fly.io Deploy + on: - push: - branches: - - main + workflow_run: + workflows: ["Publish Docker images"] + types: + - completed + jobs: deploy-node: name: Deploy Cartesi node + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest concurrency: deploy-group # optional: ensure only one action runs at a time steps: @@ -17,6 +21,7 @@ jobs: deploy-fullnode: name: Deploy fullnode + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest concurrency: deploy-group # optional: ensure only one action runs at a time steps: @@ -25,4 +30,3 @@ jobs: - run: fflyctl deploy --config fly.fullnode.toml --remote-only env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - \ No newline at end of file diff --git a/fly.fullnode.toml b/fly.fullnode.toml index 2505cc9..494f3fc 100644 --- a/fly.fullnode.toml +++ b/fly.fullnode.toml @@ -1,7 +1,7 @@ app = "cartezcash-fullnode" [build] -image = "registry.fly.io/cartezcash-fullnode" +image = "registry.fly.io/cartezcash-fullnode:latest" [[services]] internal_port = 50051 diff --git a/fly.toml b/fly.toml index a648bfd..ccf3950 100644 --- a/fly.toml +++ b/fly.toml @@ -1,7 +1,7 @@ app = "cartezcash" [build] -image = "registry.fly.io/cartezcash" +image = "registry.fly.io/cartezcash:latest" [http_service] internal_port = 10000