Skip to content

Commit

Permalink
Merge pull request #2219 from vrk-kpa/add_restart_services_workflows
Browse files Browse the repository at this point in the history
Add restart services workflows and necessary modifications
  • Loading branch information
Zharktas authored May 6, 2024
2 parents 2148e90 + d732f77 commit 105eed3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/restart_beta_containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Restart beta containers

on:
workflow_dispatch:

jobs:
restart-dev:
name: restart beta containers
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
container: ["ckan", "ckanCron", "drupal"]
steps:
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.1
with:
role-to-assume: ${{ secrets.AWS_BETA_DEPLOY_ROLE }}
role-session-name: github-actions
aws-region: eu-north-1

- name: Restart containers
run: |
aws ecs update-service --cluster ${{ secrets.beta_cluster }} --service ${{ matrix.container }} --force-new-deployment
26 changes: 26 additions & 0 deletions .github/workflows/restart_prod_containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Restart Prod containers

on:
workflow_dispatch:

jobs:
restart-prod:
name: restart prod containers
runs-on: ubuntu-latest
environment: prod
permissions:
id-token: write
strategy:
matrix:
container: ["ckan", "ckanCron", "drupal"]
steps:
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.1
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
role-session-name: github-actions
aws-region: eu-north-1

- name: Restart containers
run: |
aws ecs update-service --cluster ${{ secrets.prod_cluster }} --service ${{ matrix.container }} --force-new-deployment
2 changes: 2 additions & 0 deletions cdk/lib/ckan-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ export class CkanStack extends Stack {
this.ckanService = new ecs.FargateService(this, 'ckanService', {
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
cluster: props.cluster,
serviceName: "ckan",
taskDefinition: ckanTaskDef,
minHealthyPercent: 50,
maxHealthyPercent: 200,
Expand Down Expand Up @@ -600,6 +601,7 @@ export class CkanStack extends Stack {
this.ckanCronService = new ecs.FargateService(this, 'ckanCronService', {
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
cluster: props.cluster,
serviceName: "ckanCron",
taskDefinition: ckanCronTaskDef,
desiredCount: 1,
minHealthyPercent: 0,
Expand Down
1 change: 1 addition & 0 deletions cdk/lib/drupal-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export class DrupalStack extends Stack {
this.drupalService = new ecs.FargateService(this, 'drupalService', {
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
cluster: props.cluster,
serviceName: "drupal",
taskDefinition: drupalTaskDef,
minHealthyPercent: 50,
maxHealthyPercent: 200,
Expand Down
16 changes: 16 additions & 0 deletions cloudformation/github-actions-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ Parameters:
ECRRepositoryArn:
Description: Arn for the ECR repositories.
Type: String
CreateBuildRole:
Description: Is the build role required for this aws account
Type: String
Default: false
AllowedValues: [true, false]

Conditions:
CreateOIDCProvider: !Equals
- !Ref OIDCProviderArn
- ""
ShouldCreateBuildRole: !Equals ['true', !Ref CreateBuildRole]

Resources:
Role:
Expand Down Expand Up @@ -52,6 +58,14 @@ Resources:
Action: "ecr:GetAuthorizationToken"
Resource: "*"

- PolicyName: ecs-update-service
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "ecs:UpdateService"
Resource: "*"

- PolicyName: ecr-access
PolicyDocument:
Version: "2012-10-17"
Expand Down Expand Up @@ -100,6 +114,7 @@ Resources:

BuildRole:
Type: AWS::IAM::Role
Condition: ShouldCreateBuildRole
Properties:
Description: Role for GitHub actions build workflow.
AssumeRolePolicyDocument:
Expand Down Expand Up @@ -144,4 +159,5 @@ Outputs:
Role:
Value: !GetAtt Role.Arn
BuildRole:
Condition: ShouldCreateBuildRole
Value: !GetAtt BuildRole.Arn

0 comments on commit 105eed3

Please sign in to comment.