From cc29f54324ab3992a63d1f9ea4cb097d8c972355 Mon Sep 17 00:00:00 2001 From: Fahad <42780409+F2had@users.noreply.github.com> Date: Mon, 7 Jul 2025 22:46:18 +0300 Subject: [PATCH 1/3] ci: update workflow to deploy on prod branch --- .github/workflows/deploy.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6862850..3c8c463 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,14 +1,11 @@ -name: Deploy Docker Image - +name: Build and Deploy on: push: branches: - - '**' - + - 'prod' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - jobs: build-and-push: runs-on: ubuntu-latest @@ -17,18 +14,17 @@ jobs: packages: write attestations: write id-token: write - steps: - name: Checkout uses: actions/checkout@v4 - + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Extract metadata id: meta uses: docker/metadata-action@v5 @@ -39,11 +35,21 @@ jobs: type=ref,event=pr type=sha type=raw,value=latest,enable={{is_default_branch}} - + - name: Build and push uses: docker/build-push-action@v6 with: context: . - push: ${{ github.ref == 'refs/heads/master' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Trigger Deployment Update + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.DEPLOY_TOKEN }}" \ + -H "Content-Type: application/json" \ + ${{ secrets.DEPLOY_ENDPOINT }} + env: + DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} + DEPLOY_ENDPOINT: ${{ secrets.DEPLOY_ENDPOINT }} \ No newline at end of file From aa991c477a2859a53548eb9cec53c5052930b76d Mon Sep 17 00:00:00 2001 From: Fahad <42780409+F2had@users.noreply.github.com> Date: Mon, 7 Jul 2025 22:59:30 +0300 Subject: [PATCH 2/3] ci: Add manual prod deployment trigger --- .github/workflows/deploy-trigger.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/deploy-trigger.yml diff --git a/.github/workflows/deploy-trigger.yml b/.github/workflows/deploy-trigger.yml new file mode 100644 index 0000000..ff6e606 --- /dev/null +++ b/.github/workflows/deploy-trigger.yml @@ -0,0 +1,28 @@ +name: Deploy to Production +on: + workflow_dispatch: + inputs: + confirm_deploy: + description: 'Type "deploy" to confirm' + required: true + default: '' + +jobs: + deploy: + runs-on: ubuntu-latest + if: github.event.inputs.confirm_deploy == 'deploy' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Rebase prod to master and deploy + run: | + git config user.name "NedaaBot" + git config user.email "186649556+NedaaBot@users.noreply.github.com" + git switch master + git pull origin master + git switch prod + git rebase master + git push --force-with-lease origin prod From 7e6dbb11945e120439f7a02cbf78189b0aed6748 Mon Sep 17 00:00:00 2001 From: Fahad <42780409+F2had@users.noreply.github.com> Date: Mon, 7 Jul 2025 23:08:09 +0300 Subject: [PATCH 3/3] ci: Update deployment trigger format --- .github/workflows/deploy.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3c8c463..99ff46e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,14 +17,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Extract metadata id: meta uses: docker/metadata-action@v5 @@ -35,7 +35,7 @@ jobs: type=ref,event=pr type=sha type=raw,value=latest,enable={{is_default_branch}} - + - name: Build and push uses: docker/build-push-action@v6 with: @@ -43,13 +43,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - + - name: Trigger Deployment Update run: | - curl -X POST \ - -H "Authorization: Bearer ${{ secrets.DEPLOY_TOKEN }}" \ - -H "Content-Type: application/json" \ - ${{ secrets.DEPLOY_ENDPOINT }} - env: - DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} - DEPLOY_ENDPOINT: ${{ secrets.DEPLOY_ENDPOINT }} \ No newline at end of file + curl -H "Authorization: Bearer ${{ secrets.DEPLOY_TOKEN }}" ${{ secrets.DEPLOY_ENDPOINT }}