diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml new file mode 100644 index 00000000..0e957626 --- /dev/null +++ b/.github/workflows/deploy_dev.yml @@ -0,0 +1,35 @@ +name: Deploy Pantau Rilis Dev with Ansible + +on: + pull_request: + branches: [rilis-dev] + types: [closed] + +permissions: + contents: read + +concurrency: + group: deploy-pantau-dev + cancel-in-progress: true + +jobs: + deploy: + if: github.event.pull_request.merged == true + name: Deploy Pantau Rilis Dev to Production Server + runs-on: ubuntu-latest + + steps: + - name: Checkout Ansible Code + uses: actions/checkout@v4 + + - name: Deploy via SSH using appleboy/ssh-action + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.CICD_SERVER_IP }} + username: ${{ secrets.CICD_SERVER_USER }} + key: ${{ secrets.CICD_SERVER_PRIVATE_KEY }} + port: ${{ secrets.CICD_SERVER_PORT }} + script: | + set -euo pipefail + cd ${{ secrets.CICD_SERVER_PATH }} + ansible-playbook -i inventories/production/inventory.yml playbooks/deploy-pantau-dev.yml diff --git a/.github/workflows/deploy_rilis.yml b/.github/workflows/deploy_rilis.yml new file mode 100644 index 00000000..22dcaeb1 --- /dev/null +++ b/.github/workflows/deploy_rilis.yml @@ -0,0 +1,35 @@ +name: Deploy Pantau Rilis with Ansible + +on: + release: + types: [published] + +permissions: + contents: read + +concurrency: + group: deploy-pantau-rilis + cancel-in-progress: true + +jobs: + deploy: + # rilis dari branch 'master' & bukan prerelease + if: github.event.release.target_commitish == 'master' && github.event.release.prerelease == false + name: Deploy Pantau Rilis to Production Server + runs-on: ubuntu-latest + + steps: + - name: Checkout Ansible Code + uses: actions/checkout@v4 + + - name: Deploy via SSH using appleboy/ssh-action + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.CICD_SERVER_IP }} + username: ${{ secrets.CICD_SERVER_USER }} + key: ${{ secrets.CICD_SERVER_PRIVATE_KEY }} + port: ${{ secrets.CICD_SERVER_PORT }} + script: | + set -euo pipefail + cd ${{ secrets.CICD_SERVER_PATH }} + ansible-playbook -i inventories/production/inventory.yml playbooks/deploy-pantau-rilis.yml --extra-vars "release_tag=${{ github.event.release.tag_name }}"