From 15abbe8a60ba224ed9924ade00dc34406ccbb646 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Thu, 11 Nov 2021 19:40:19 +0100 Subject: Rename ci-cd workflow to deploy since it's manual now --- .github/workflows/ci-cd.yml | 92 -------------------------------------------- .github/workflows/deploy.yml | 92 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 92 deletions(-) delete mode 100644 .github/workflows/ci-cd.yml create mode 100644 .github/workflows/deploy.yml (limited to '.github') diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml deleted file mode 100644 index b8f2e64f..00000000 --- a/.github/workflows/ci-cd.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: ci-cd - -on: - workflow_dispatch: {} - -env: - DOCKERHUB_USER: hildan - DOCKER_IMAGE_NAME: seven-wonders-server - DOCKER_IMAGE_TAG_SHA: sha-${{ github.sha }} - DOCKER_IMAGE_TAG_BUILD: build-${{ github.run_id }} - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - distribution: 'zulu' - java-version: 17 - - - name: Build with Gradle - uses: burrunan/gradle-cache-action@v1 - with: - job-id: jdk17 - arguments: build - - # required for Docker build/push - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ env.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }} - - - name: Build and push to DockerHub and GitHub Container Registry - uses: docker/build-push-action@v2 - with: - context: ./sw-server - file: ./sw-server/Dockerfile - push: true - tags: | - ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:latest - ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_SHA }} - ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }} - ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:latest - ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_SHA }} - ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }} - - - name: Install doctl - uses: digitalocean/action-doctl@v2 - with: - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - # Short-lived credentials (5 min) to avoid accumulating tokens - - name: Setup DigitalOcean kubeconfig - run: doctl kubernetes cluster kubeconfig save --expiry-seconds 300 bro-cluster - - - name: Update deployment file - run: TAG=${{ env.DOCKER_IMAGE_TAG_BUILD }} && sed -i 's|:latest|:'${TAG}'|' kubernetes/server.yml - - - name: Notify deploy start - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SEVEN_WONDERS }} - uses: Ilshidur/action-discord@0.3.2 - with: - args: "[Build #${{github.run_id}}](): Deploying new version `${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }}` ([see changes](<{{ EVENT_PAYLOAD.compare }}>))..." - - - name: Deploy to DigitalOcean Kubernetes - run: kubectl apply -f kubernetes - - - name: Verify deployment - run: kubectl rollout status --namespace seven-wonders deployment/seven-wonders - - - name: Notify deploy success - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SEVEN_WONDERS }} - uses: Ilshidur/action-discord@0.3.2 - with: - args: 'Deployment successful!' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..75757802 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,92 @@ +name: deploy + +on: + workflow_dispatch: {} + +env: + DOCKERHUB_USER: hildan + DOCKER_IMAGE_NAME: seven-wonders-server + DOCKER_IMAGE_TAG_SHA: sha-${{ github.sha }} + DOCKER_IMAGE_TAG_BUILD: build-${{ github.run_id }} + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 17 + + - name: Build with Gradle + uses: burrunan/gradle-cache-action@v1 + with: + job-id: jdk17 + arguments: build + + # required for Docker build/push + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ env.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }} + + - name: Build and push to DockerHub and GitHub Container Registry + uses: docker/build-push-action@v2 + with: + context: ./sw-server + file: ./sw-server/Dockerfile + push: true + tags: | + ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_SHA }} + ${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }} + ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_SHA }} + ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }} + + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + # Short-lived credentials (5 min) to avoid accumulating tokens + - name: Setup DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save --expiry-seconds 300 bro-cluster + + - name: Update deployment file + run: TAG=${{ env.DOCKER_IMAGE_TAG_BUILD }} && sed -i 's|:latest|:'${TAG}'|' kubernetes/server.yml + + - name: Notify deploy start + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SEVEN_WONDERS }} + uses: Ilshidur/action-discord@0.3.2 + with: + args: "[Build #${{github.run_id}}](): Deploying new version `${{ env.DOCKERHUB_USER }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG_BUILD }}` ([see changes](<{{ EVENT_PAYLOAD.compare }}>))..." + + - name: Deploy to DigitalOcean Kubernetes + run: kubectl apply -f kubernetes + + - name: Verify deployment + run: kubectl rollout status --namespace seven-wonders deployment/seven-wonders + + - name: Notify deploy success + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SEVEN_WONDERS }} + uses: Ilshidur/action-discord@0.3.2 + with: + args: 'Deployment successful!' -- cgit