Skip to content

Commit 4c67b5c

Browse files
committed
Add deployment pipeline
1 parent 6c05951 commit 4c67b5c

File tree

2 files changed

+56
-9
lines changed

2 files changed

+56
-9
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: deploy-to-digital-ocean.yml
2+
on:
3+
workflow_call:
4+
inputs:
5+
version:
6+
required: true
7+
type: string
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Docker image tag to deploy'
12+
required: true
13+
default: 'latest'
14+
15+
jobs:
16+
deploy:
17+
# do not execute on forks
18+
if: ${{ github.repository == 'HackYourFuture/CourseHub' }}
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
environment: coursehub.hyf.dev
24+
concurrency: coursehub.hyf.dev
25+
steps:
26+
- name: Deploy coursehub
27+
uses: digitalocean/app_action/deploy@v2
28+
env:
29+
IMAGE_TAG_COURSE_HUB: ${{ inputs.version }}
30+
with:
31+
app_name: coursehub
32+
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ on:
88
version:
99
description: 'Version to release (must start with "v")'
1010
required: true
11+
deploy:
12+
description: 'Deploy to DigitalOcean'
13+
required: false
14+
default: false
15+
type: boolean
1116

1217
jobs:
1318
build-image:
1419
runs-on: ubuntu-latest
1520
permissions:
1621
contents: read
1722
packages: write
18-
attestations: write
19-
id-token: write
2023
outputs:
21-
digest: ${{ steps.push.outputs.digest }}
22-
tags: ${{ steps.meta.outputs.tags }}
24+
version: ${{ steps.get-version.outputs.version }}
2325
steps:
2426
- uses: actions/checkout@v5
2527

@@ -40,14 +42,27 @@ jobs:
4042
username: ${{ github.actor }}
4143
password: ${{ secrets.GITHUB_TOKEN }}
4244

43-
- name: Build
44-
env:
45-
DOCKER_PUSH: true
45+
- id: get-version
4646
run: |
4747
# Determine version from tag or input
48-
VERSION="${{ github.event.inputs.version || '' }}"
48+
VERSION="${{ inputs.version || '' }}"
4949
if [ -z "$VERSION" ]; then
5050
VERSION="${GITHUB_REF_NAME#v}"
5151
fi
52+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
5253
53-
./gradlew -Pversion=$VERSION bootBuildImage
54+
- name: Build
55+
env:
56+
DOCKER_PUSH: true
57+
run: ./gradlew -Pversion=${{ steps.get-version.outputs.version }} bootBuildImage
58+
59+
deploy:
60+
# do not execute on forks
61+
if: ${{ github.repository == 'HackYourFuture/CourseHub' && inputs.deploy }}
62+
needs: build-image
63+
permissions:
64+
contents: read
65+
uses: ./.github/workflows/deploy-to-digital-ocean.yml
66+
secrets: inherit
67+
with:
68+
version: ${{ needs.build-image.outputs.version }}

0 commit comments

Comments
 (0)