-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (98 loc) · 3.09 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Release
on:
push:
branches: [ main ]
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
permissions:
issues: write
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for semantic-release
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '22'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install semantic-release
run: |
npm install -g @semantic-release/commit-analyzer@12.0.0 \
@semantic-release/release-notes-generator@13.0.0 \
@semantic-release/exec@6.0.3 \
@semantic-release/github@11.0.0 \
semantic-release@23.1.1 \
conventional-changelog-conventionalcommits@7.0.2
- name: Release
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
- name: Check version
id: check-version
run: >
if [ -f VERSION ]; then
VERSION=$(cat VERSION)
echo "Resolved version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "No version produced."
echo "version=" >> $GITHUB_OUTPUT
fi
publish:
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.version != '' # Skip deploy if no version is set
permissions:
id-token: write
env:
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GH_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and Push Image
uses: docker/build-push-action@v4
with:
push: true
tags: |
${{ env.ECR_REGISTRY }}/pillarbox-monitoring-transfer:${{ needs.release.outputs.version }}
${{ env.ECR_REGISTRY }}/pillarbox-monitoring-transfer:latest
deploy-dev:
runs-on: ubuntu-latest
needs: publish
permissions:
id-token: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GH_DEV_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: ECS deployment
run: >
aws ecs update-service \
--cluster pillarbox-monitoring-cluster \
--service data-transfer-service \
--force-new-deployment \
--region ${{ secrets.AWS_REGION }} >/dev/null