From 90ec340f20f77b7e85552c403f27c5af61dbf16f Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Mon, 3 Jun 2024 11:05:34 +0100 Subject: [PATCH 1/2] split out test.yml, run on:pull_request --- .github/workflows/test.yml | 58 +++----------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32742b7a8..17131cda9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: test on: - pull_request_target: + pull_request: push: branches: - main @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 - build: + build-image: needs: [ruff] runs-on: ubuntu-latest steps: @@ -38,7 +38,7 @@ jobs: name: warnet path: /tmp/warnet.tar test: - needs: [build] + needs: [build-image] runs-on: ubuntu-latest strategy: matrix: @@ -56,59 +56,9 @@ jobs: - name: Run tests run: ./test/${{matrix.test}} ${{matrix.backend}} build-test: - needs: [build, test] + needs: [build-image] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/compose - run: ./test/build_branch_test.py compose - deploy: - needs: [build-test] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }} - tags: | - type=ref,event=tag - type=ref,event=pr - type=raw,value=latest,enable={{is_default_branch}} - labels: | - maintainer=bitcoindevproject - org.opencontainers.image.title=warnet-rpc - org.opencontainers.image.description=Warnet RPC server - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push production RPC image - uses: docker/build-push-action@v5 - with: - file: src/templates/rpc/Dockerfile_rpc - platforms: linux/amd64,linux/arm64 - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Build and push dev RPC image - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 - with: - file: src/templates/rpc/Dockerfile_rpc_dev - platforms: linux/amd64,linux/arm64 - context: . - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max From c84b643ae0295aff63f84cdc458dc5bf51a5658c Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Mon, 3 Jun 2024 11:05:48 +0100 Subject: [PATCH 2/2] add deploy.yml, run on:workflow --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..7141d5265 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: deploy + +on: + workflow_run: + workflows: ["test"] + types: + - completed + +jobs: + deploy-to-dockerhub: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.conclusion == 'success' + steps: + - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }} + tags: | + type=ref,event=tag + type=ref,event=pr + type=raw,value=latest,enable={{is_default_branch}} + labels: | + maintainer=bitcoindevproject + org.opencontainers.image.title=warnet-rpc + org.opencontainers.image.description=Warnet RPC server + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push production RPC image + uses: docker/build-push-action@v5 + with: + file: src/templates/rpc/Dockerfile_rpc + platforms: linux/amd64,linux/arm64 + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Build and push dev RPC image + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@v5 + with: + file: src/templates/rpc/Dockerfile_rpc_dev + platforms: linux/amd64,linux/arm64 + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max