Skip to content

Commit f6f9001

Browse files
ToothyDevCopilot
andauthored
feat: 👷 Split CI and CD flows (#31)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 2a5f945 commit f6f9001

4 files changed

Lines changed: 31 additions & 14 deletions

File tree

.github/workflows/CD.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
permissions:
8+
contents: read
9+
packages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: deploy-${{ github.ref_name }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
CI:
18+
uses: ./.github/workflows/CI.yml
19+
deploy:
20+
needs: CI
21+
if: ${{ needs.CI.result == 'success' }}
22+
permissions: {}
23+
uses: ./.github/workflows/deploy.yml
24+
secrets:
25+
COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }}
26+
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}

.github/workflows/CI.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
name: CI/CD
1+
name: CI
22

33
on:
4-
push:
5-
branches: [ "main" ]
4+
workflow_call:
65
pull_request:
76
branches: [ "main" ]
87

@@ -22,11 +21,3 @@ jobs:
2221
packages: write
2322
id-token: write
2423
uses: ./.github/workflows/docker.yml
25-
deploy:
26-
permissions: {}
27-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
28-
needs: docker
29-
uses: ./.github/workflows/deploy.yml
30-
secrets:
31-
COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }}
32-
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
steps:
1818
- name: Deploy
1919
run: |
20-
curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
20+
curl --fail-with-body --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
2727

2828
- name: Log into registry ${{ env.REGISTRY }}
29+
if: github.ref == 'refs/heads/main'
2930
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
3031
with:
3132
registry: ${{ env.REGISTRY }}
@@ -39,15 +40,14 @@ jobs:
3940
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4041
tags: |
4142
type=ref,event=branch
42-
type=ref,event=pr
4343
type=ref,event=tag
4444
type=sha
4545
4646
- name: Build and push Docker image
4747
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
4848
with:
4949
context: .
50-
push: true
50+
push: ${{ github.ref == 'refs/heads/main' }}
5151
tags: ${{ steps.meta.outputs.tags }}
5252
labels: ${{ steps.meta.outputs.labels }}
5353
cache-from: type=gha

0 commit comments

Comments
 (0)