mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-15 00:29:38 +00:00
Update ci-cd.yml, Slack integration [skip ci]
This commit is contained in:
parent
1a193e0ed2
commit
f7c1d2a270
1 changed files with 22 additions and 20 deletions
40
.github/workflows/ci-cd.yml
vendored
40
.github/workflows/ci-cd.yml
vendored
|
@ -11,10 +11,13 @@ jobs:
|
||||||
uses: ./.github/workflows/sonarcloud.yml
|
uses: ./.github/workflows/sonarcloud.yml
|
||||||
secrets:
|
secrets:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||||
|
SLACK_CI_CHANNEL_ID: ${{ secrets.SLACK_CI_CHANNEL_ID }}
|
||||||
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
needs: sonarcloud
|
needs: sonarcloud
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment: docker-push # Requires review before proceeding
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -45,11 +48,12 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials with LabRole
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
with:
|
with:
|
||||||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/LabRole
|
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/LabRole
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
|
role-session-name: GitHubActionsSession
|
||||||
|
|
||||||
- name: Setup Terraform
|
- name: Setup Terraform
|
||||||
uses: hashicorp/setup-terraform@v3
|
uses: hashicorp/setup-terraform@v3
|
||||||
|
@ -64,33 +68,29 @@ jobs:
|
||||||
run: terraform apply -auto-approve -var "image_tag=${{ github.sha }}" -var "environment=staging" -var "dockerhub_username=${{ secrets.DOCKERHUB_USERNAME }}"
|
run: terraform apply -auto-approve -var "image_tag=${{ github.sha }}" -var "environment=staging" -var "dockerhub_username=${{ secrets.DOCKERHUB_USERNAME }}"
|
||||||
working-directory: ./terraform
|
working-directory: ./terraform
|
||||||
|
|
||||||
- name: Send Slack Notification (Staging)
|
- name: Send Slack Notification (Staging Complete, Pending Production Review)
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
uses: slackapi/slack-github-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
|
method: chat.postMessage
|
||||||
channel-id: 'staging-deployments'
|
token: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||||
text: "Staging Deployment: ${{ job.status }} for commit ${{ github.sha }}"
|
payload: |
|
||||||
|
channel: ${{ secrets.SLACK_PROD_CHANNEL_ID }}
|
||||||
approval:
|
text: "Staging Deployment Complete: ${{ job.status }} for commit ${{ github.sha }}. Production deployment is pending review in GitHub Actions."
|
||||||
needs: deploy-staging
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment: production
|
|
||||||
steps:
|
|
||||||
- name: Manual Approval
|
|
||||||
run: echo "Waiting for manual approval..."
|
|
||||||
|
|
||||||
deploy-production:
|
deploy-production:
|
||||||
needs: approval
|
needs: deploy-staging
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment: production # Requires review before proceeding
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials with LabRole
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
with:
|
with:
|
||||||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/LabRole
|
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/LabRole
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
|
role-session-name: GitHubActionsSession
|
||||||
|
|
||||||
- name: Setup Terraform
|
- name: Setup Terraform
|
||||||
uses: hashicorp/setup-terraform@v3
|
uses: hashicorp/setup-terraform@v3
|
||||||
|
@ -106,8 +106,10 @@ jobs:
|
||||||
working-directory: ./terraform
|
working-directory: ./terraform
|
||||||
|
|
||||||
- name: Send Slack Notification (Production)
|
- name: Send Slack Notification (Production)
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
uses: slackapi/slack-github-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
|
method: chat.postMessage
|
||||||
channel-id: 'production-deployments'
|
token: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||||
|
payload: |
|
||||||
|
channel: ${{ secrets.SLACK_PROD_CHANNEL_ID }}
|
||||||
text: "Production Deployment: ${{ job.status }} for commit ${{ github.sha }}"
|
text: "Production Deployment: ${{ job.status }} for commit ${{ github.sha }}"
|
||||||
|
|
Loading…
Reference in a new issue