CD Pipeline #106
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD Pipeline | |
| on: | |
| workflow_run: | |
| workflows: ["CI Pipeline"] | |
| types: | |
| - completed | |
| jobs: | |
| deploy-services: | |
| runs-on: self-hosted | |
| environment: production | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - name: Docker Login | |
| run: | | |
| echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
| - name: Get CI Commit SHA | |
| id: get_sha | |
| run: echo "sha=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_OUTPUT | |
| - name: Deploy Services to Swarm | |
| env: | |
| APP_IMAGE_TAG: ${{ steps.get_sha.outputs.sha }} | |
| run: | | |
| DEPLOY_PATH="." | |
| cd "${DEPLOY_PATH}" | |
| APP_IMAGE_TAG="${APP_IMAGE_TAG}" docker stack deploy -c docker-swarm.yml --with-registry-auth ecommerce | |
| - name: Docker Logout | |
| run: docker logout |