feat: add alias creation and refactor setup process #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |