-
Notifications
You must be signed in to change notification settings - Fork 8
50 lines (43 loc) · 1.44 KB
/
keycloak-deploy.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
name: Deploy Keycloak Image to ECR
permissions:
id-token: write
contents: read
on:
workflow_dispatch:
inputs:
environment:
description: Environment to deploy to
required: true
type: choice
options:
- dev
- prod
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }}
role-session-name: "github-${{ github.repository }}-${{ github.run_id }}"
aws-region: "us-west-2"
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push Docker image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: keycloak-${{ github.event.inputs.environment }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./terraform/aws/modules/keycloak/resources
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Cleanup Docker images
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: keycloak-dev
IMAGE_TAG: latest
run: docker rmi $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG