From 35c6da30d0a558c36ee61c532dcb6bfd1aa771e6 Mon Sep 17 00:00:00 2001 From: Alex Dyakonov Date: Sat, 26 Oct 2024 20:47:10 +0300 Subject: [PATCH] Added dev cd pipline --- .github/workflows/cd-dev.yaml | 49 +++++++++++++++++++ ...ld-push-deploy.yaml => cd-production.yaml} | 0 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/cd-dev.yaml rename .github/workflows/{cd-build-push-deploy.yaml => cd-production.yaml} (100%) diff --git a/.github/workflows/cd-dev.yaml b/.github/workflows/cd-dev.yaml new file mode 100644 index 0000000..4aa4d43 --- /dev/null +++ b/.github/workflows/cd-dev.yaml @@ -0,0 +1,49 @@ +name: CD Dev + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + deploy_to_dev: + name: Deploy to Dev + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'dev' }} + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set short git commit SHA + id: vars + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: | + shampiniony/dishdash-bot:dev + shampiniony/dishdash-bot:dev-${{ env.COMMIT_SHORT_SHA }} + + - name: Trigger Watchtower to update dev container + shell: bash + run: | + curl -H "Authorization: Bearer ${{ secrets.WATCHTOWER_HTTP_API_TOKEN }}" ${{ secrets.WATCHTOWER_UPDATE_ENDPOINT_DEV }} diff --git a/.github/workflows/cd-build-push-deploy.yaml b/.github/workflows/cd-production.yaml similarity index 100% rename from .github/workflows/cd-build-push-deploy.yaml rename to .github/workflows/cd-production.yaml