| 1 | name: Build and release image |
| 2 | |
| 3 | on: |
| 4 | workflow_run: |
| 5 | workflows: ["Build and test image"] |
| 6 | types: |
| 7 | - completed |
| 8 | branches: ["v*.*.*"] |
| 9 | workflow_dispatch: |
| 10 | |
| 11 | concurrency: |
| 12 | group: falkordb-node-release |
| 13 | cancel-in-progress: true |
| 14 | |
| 15 | env: |
| 16 | NODE_IMAGE_NAME: falkordb-node |
| 17 | CLUSTER_IMAGE_NAME: falkordb-cluster |
| 18 | FALKORDB_VERSION: v4.2.1 |
| 19 | CLUSTER_REBALANCE_IMAGE_NAME: falkordb-cluster-rebalance |
| 20 | |
| 21 | jobs: |
| 22 | build-and-push: |
| 23 | runs-on: ubuntu-latest |
| 24 | strategy: |
| 25 | fail-fast: true |
| 26 | matrix: |
| 27 | include: |
| 28 | - dockerfile: ./falkordb-node/Dockerfile |
| 29 | image-name: falkordb-node |
| 30 | - dockerfile: ./falkordb-cluster/Dockerfile |
| 31 | image-name: falkordb-cluster |
| 32 | - dockerfile: ./falkordb-cluster-rebalance/Dockerfile |
| 33 | image-name: falkordb-cluster-rebalance |
| 34 | steps: |
| 35 | - run: ${{ tojson(github.event) }} |
| 36 | shell: cat {0} |
| 37 | |
| 38 | - name: Checkout |
| 39 | uses: actions/checkout@v4 |
| 40 | |
| 41 | - name: Set up Docker Buildx |
| 42 | uses: docker/setup-buildx-action@v3 |
| 43 | |
| 44 | - name: Login to Docker Hub |
| 45 | uses: docker/login-action@v3 |
| 46 | with: |
| 47 | username: ${{ secrets.DOCKER_USERNAME }} |
| 48 | password: ${{ secrets.DOCKER_PASSWORD }} |
| 49 | |
| 50 | - name: Build and push |
| 51 | uses: docker/build-push-action@v5 |
| 52 | with: |
| 53 | build-args: FALKORDB_VERSION=${{ env.FALKORDB_VERSION }} |
| 54 | context: . |
| 55 | file: ${{ matrix.dockerfile }} |
| 56 | push: true |
| 57 | tags: falkordb/${{ matrix.image-name }}:${{ github.event.workflow_run.head_branch }}, falkordb/${{ matrix.image-name }}:latest |
| 58 | |
| 59 | omnistrate-update-plans: |
| 60 | needs: build-and-push |
| 61 | runs-on: ubuntu-latest |
| 62 | strategy: |
| 63 | fail-fast: false |
| 64 | max-parallel: 1 |
| 65 | matrix: |
| 66 | plans: |
| 67 | - name: FalkorDB |
| 68 | file: omnistrate.free.yaml |
| 69 | key: free |
| 70 | - name: FalkorDB |
| 71 | file: omnistrate.pro.yaml |
| 72 | key: pro |
| 73 | steps: |
| 74 | - name: Checkout |
| 75 | if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }} |
| 76 | uses: actions/checkout@v4 |
| 77 | |
| 78 | - name: Replace Variables |
| 79 | if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }} |
| 80 | run: | |
| 81 | sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' ${{ matrix.plans.file }} |
| 82 | sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' ${{ matrix.plans.file }} |
| 83 | sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' ${{ matrix.plans.file }} |
| 84 | sed -i 's/$AwsAccountId/${{ vars.AWS_ACCOUNT_ID }}/g' ${{ matrix.plans.file }} |
| 85 | sed -i 's|$AwsBootstrapRoleAccountArn|${{ vars.AWS_BOOTSTRAP_ROLE_ACCOUNT_ARN }}|g' ${{ matrix.plans.file }} |
| 86 | sed -i 's/$FalkorDBNodeImage/falkordb\/${{ env.NODE_IMAGE_NAME }}:${{ github.event.workflow_run.head_branch }}/g' ${{ matrix.plans.file }} |
| 87 | sed -i 's/$FalkorDBClusterImage/falkordb\/${{ env.CLUSTER_IMAGE_NAME }}:${{ github.event.workflow_run.head_branch }}/g' ${{ matrix.plans.file }} |
| 88 | sed -i 's/$FalkorDBClusterRebalanceImage/falkordb\/${{ env.CLUSTER_REBALANCE_IMAGE_NAME }}:${{ github.event.workflow_run.head_branch }}/g' ${{ matrix.plans.file }} |
| 89 | |
| 90 | - name: Remove e2-machine and t2.medium from pro |
| 91 | if: ${{ contains( vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) && matrix.plans.key == 'pro' }} |
| 92 | run: | |
| 93 | sed -i 's/- e2-medium//g' ${{ matrix.plans.file }} |
| 94 | sed -i 's/- t2.medium//g' ${{ matrix.plans.file }} |
| 95 | |
| 96 | - name: Upload yaml to artifacts |
| 97 | if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }} |
| 98 | uses: actions/upload-artifact@v4 |
| 99 | with: |
| 100 | name: ${{ matrix.plans.file }} |
| 101 | path: ${{ matrix.plans.file }} |
| 102 | |
| 103 | - name: Create FALKORDB_PASSWORD/ADMIN_PASSWORD files |
| 104 | run: | |
| 105 | export sec=$(grep '^secrets' omnistrate.free.yaml) |
| 106 | if [[ -n "$sec" ]];then |
| 107 | mkdir -p secrets || { echo "Failed to create secrets directory"; exit 1; } |
| 108 | echo '{{ $var.falkordbPassword }}' > ./secrets/falkordbpassword || { echo "Failed to write falkordbpassword"; exit 1; } |
| 109 | echo '{{ $func.random(string, 16, $sys.deterministicSeedValue) }}' > ./secrets/adminpassword || { echo "Failed to write adminpassword"; exit 1; } |
| 110 | else |
| 111 | echo "secrets option was not used" |
| 112 | exit 0 |
| 113 | fi |
| 114 | |
| 115 | - name: Update Omnistrate plan |
| 116 | if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }} |
| 117 | uses: ./.github/actions/update-omnistrate-plan |
| 118 | with: |
| 119 | username: ${{ secrets.OMNISTRATE_USERNAME }} |
| 120 | password: ${{ secrets.OMNISTRATE_PASSWORD }} |
| 121 | file: ${{ matrix.plans.file }} |
| 122 | service-name: ${{ matrix.plans.name }} |
| 123 | environment: dev |
| 124 | environment-type: dev |