Skip to content

Commit fb6fe33

Browse files
committed
feat: checkout branch name on build and deploy
1 parent 21f91fb commit fb6fe33

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

.github/workflows/pull-request-action.yaml

+28-9
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ name: Pull request comment
22

33
on:
44
issue_comment:
5-
types: [created, edited, deleted]
5+
types: [created]
66

77
jobs:
8-
output-context:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Dump GitHub context
12-
env:
13-
GITHUB_CONTEXT: ${{ toJSON(github) }}
14-
run: echo "$GITHUB_CONTEXT"
8+
# output-context:
9+
# runs-on: ubuntu-latest
10+
# steps:
11+
# - name: Dump GitHub context
12+
# env:
13+
# GITHUB_CONTEXT: ${{ toJSON(github) }}
14+
# run: echo "$GITHUB_CONTEXT"
1515

1616
get-branch-name:
1717
runs-on: ubuntu-latest
@@ -25,7 +25,17 @@ jobs:
2525
env:
2626
GH_TOKEN: ${{ github.token }}
2727

28-
build-and-deploy:
28+
pre-deploy:
29+
# check if the comment comes from a pull request and contains the required keyword
30+
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/deploy')
31+
runs-on: ubuntu-latest
32+
steps:
33+
- run: |
34+
gh issue comment ${{ github.event.issue.number }} --body "Preview environment deploying..." --repo ${{ github.repository }}
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
38+
deploy:
2939
# check if the comment comes from a pull request and contains the required keyword
3040
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/deploy')
3141
needs: get-branch-name
@@ -34,3 +44,12 @@ jobs:
3444
deploy: true
3545
branchName: ${{ needs.get-branch-name.outputs.branchName }}
3646
secrets: inherit
47+
48+
post-deploy:
49+
runs-on: ubuntu-latest
50+
needs: deploy
51+
steps:
52+
- run: |
53+
gh issue comment ${{ github.event.issue.number }} --body "Preview environment deployed: https://${{ needs.deploy.outputs.container-app-url }}" --repo ${{ github.repository }}
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/shared-build-and-deploy.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
steps:
3737
- name: Checkout repository
3838
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ inputs.branchName }}
3941

4042
- name: Set sha-short and image-name environment variables
4143
id: vars

0 commit comments

Comments
 (0)