1
+ name : ' DC: Edit'
2
+
3
+ on :
4
+ workflow_call :
5
+
6
+ # Special permissions required for OIDC authentication
7
+ permissions :
8
+ id-token : write
9
+ contents : read
10
+ actions : read
11
+
12
+ env :
13
+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
14
+
15
+ jobs :
16
+ dc-edit :
17
+ name : ' Docker Compose: Edit Service'
18
+ runs-on : [self-hosted, "${{ github.event_name == 'release' && 'prod' || github.event.pull_request.base.ref }}"]
19
+ environment : ${{ github.event_name == 'release' && 'prod' || github.event.pull_request.base.ref }}
20
+ env :
21
+ ENVIRONMENT_NAME : ${{ github.event_name == 'release' && 'prod' || github.event.pull_request.base.ref }}
22
+ DEPLOYMENT_REPO_NAME : ${{ vars.DEPLOYMENT_REPO_NAME }}
23
+ CONTAINER_REGISTRY : " ${{ vars.CONTAINER_REGISTRY }}"
24
+ IMAGE_TAG : ${{ github.event_name == 'release' && github.event.release.tag_name || 'dev' }}
25
+ steps :
26
+ # Checkout the repository to the GitHub Actions runner
27
+ - name : Checkout
28
+ uses : actions/checkout@v4
29
+ with :
30
+ token : ${{ secrets.GH_TOKEN }}
31
+ repository : ${{ github.repository_owner }}/${{ env.DEPLOYMENT_REPO_NAME }}
32
+ fetch-depth : 0
33
+
34
+ - name : GitHub Configuration
35
+ run : git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com
36
+
37
+ - name : Clone cicd-deployment-scripts
38
+ run : git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git
39
+
40
+ - name : Perform Edit/Git Operations
41
+ shell : bash
42
+ run : |
43
+ AUTOMATED_RELEASE_BRANCH="automated-release-${{ github.event_name == 'release' && 'prod' || 'dev' }}"
44
+
45
+ git checkout $AUTOMATED_RELEASE_BRANCH || git checkout -b $AUTOMATED_RELEASE_BRANCH
46
+ git push origin $AUTOMATED_RELEASE_BRANCH && git pull origin $AUTOMATED_RELEASE_BRANCH
47
+
48
+ bash cicd-deployment-scripts/dc/edit.sh \
49
+ -e ${{ env.ENVIRONMENT_NAME }} \
50
+ -r ${{ env.CONTAINER_REGISTRY }} \
51
+ -s ${{ github.event.repository.name }} \
52
+ -t ${{ env.IMAGE_TAG }}
53
+
54
+ git config --global user.email "[email protected] "
55
+ git config --global user.name "GitHub Actions"
56
+
57
+ git add .env.${{ env.ENVIRONMENT_NAME }}
58
+ git commit -m "ci(${{ github.event.repository.name }}): ${{ env.IMAGE_TAG }}" || true
59
+ git push origin $AUTOMATED_RELEASE_BRANCH
60
+
61
+ PR_TITLE="ci: $AUTOMATED_RELEASE_BRANCH"
62
+ if [ ${{ github.event_name }} == 'release' ]; then
63
+ PR_TITLE="ci(release): $AUTOMATED_RELEASE_BRANCH"
64
+ fi
65
+
66
+ bash cicd-deployment-scripts/gh/pr_create.sh \
67
+ -b dev \
68
+ -h "$AUTOMATED_RELEASE_BRANCH" \
69
+ -t "$PR_TITLE" \
70
+ -o "${{ github.repository_owner }}" \
71
+ -r "${{ github.event.repository.name }}" \
72
+ -n "${{ github.event.pull_request.number }}" \
73
+ -k "${{ env.DEPLOYMENT_REPO_NAME }}" \
0 commit comments