Skip to content

Commit 02a0aa2

Browse files
authored
Simplify
Updated conditions for pull request actions and commented out unused code.
1 parent 94b5ca8 commit 02a0aa2

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: CI/CD Pipeline
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- "*"
4+
#push:
5+
# branches:
6+
# - main
7+
# - "*"
88

99
pull_request:
1010
types: [opened, ready_for_review, synchronize, closed]
@@ -21,7 +21,7 @@ permissions:
2121
jobs:
2222
auto_assign:
2323
runs-on: ubuntu-latest
24-
if: github.event_name == 'pull_request'
24+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
2525
steps:
2626
- name: Checkout code
2727
uses: actions/checkout@v4
@@ -113,7 +113,10 @@ jobs:
113113
# Build stage - converting md file to html using MkDocs
114114
convert_md_to_html:
115115
runs-on: ubuntu-latest
116-
if: github.ref != 'refs/heads/main' # Run for non-main branches
116+
#if: github.ref != 'refs/heads/main' # Run for non-main branches
117+
if: github.event_name == 'pull_request' &&
118+
github.event.action != 'closed' &&
119+
github.event.pull_request.base.ref == 'main'
117120
steps:
118121
- name: Checkout code
119122
uses: actions/checkout@v4
@@ -149,7 +152,10 @@ jobs:
149152
deploy_to_test:
150153
needs: convert_md_to_html
151154
runs-on: ubuntu-latest
152-
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' # Run for non-main branches
155+
#if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' # Run for non-main branches
156+
if: github.event_name == 'pull_request' &&
157+
github.event.action != 'closed' &&
158+
github.event.pull_request.base.ref == 'main'
153159
steps:
154160
- name: Checkout code
155161
uses: actions/checkout@v4
@@ -197,26 +203,27 @@ jobs:
197203
role-to-assume: arn:aws:iam::677043464939:role/GitHubAction-AssumeRoleWithAction
198204
role-session-name: GitHub_to_AWS_via_FederatedOIDC
199205
aws-region: ${{ secrets.AWS_REGION }}
200-
- name: Get PR number from GitHub API
201-
id: pr
202-
run: |
203-
echo "Before pr_number=$PR_NUMBER"
204-
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
205-
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
206-
-H "Authorization: Bearer $GITHUB_TOKEN" \
207-
$PR_API_URL | jq '.[0].number')
208-
echo "after pr_number=$PR_NUMBER"
209-
env:
210-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206+
#- name: Get PR number from GitHub API
207+
# id: pr
208+
# run: |
209+
# echo "Before pr_number=$PR_NUMBER"
210+
# PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
211+
# PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
212+
# -H "Authorization: Bearer $GITHUB_TOKEN" \
213+
# $PR_API_URL | jq '.[0].number')
214+
# echo "after pr_number=$PR_NUMBER"
215+
# env:
216+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211217

212218
- name: Deploy to Production Environment
213219
env:
214220
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
215-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
PR_NUMBER: ${{ github.event.pull_request.number }}
216223
run: |
217224
echo "inside pr_number=$PR_NUMBER"
218225
echo "Before pr_number=$PR_NUMBER"
219-
PR_NUMBER=${{ github.event.pull_request.number }}
226+
#PR_NUMBER=${{ github.event.pull_request.number }}
220227
echo "USING PR_NUMBER =$PR_NUMBER"
221228
222229
#PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"

0 commit comments

Comments
 (0)