Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add deployment workflow #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/aws-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[default]
region = eu-west-3
output = json

[profile ippon-sandbox]
aws_access_key_id = __AWS_ACCESS_KEY_ID__
aws_secret_access_key = __AWS_SECRET_ACCESS_KEY__
86 changes: 86 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---

name: Deployment

on:
push:
branches: [main]
pull_request:
branches: [main]

defaults:
run:
shell: bash

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
terraform:
name: Terraform
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ~1.0

- name: Setup Terragrunt
uses: autero1/action-terragrunt@v1.2.0
with:
terragrunt_version: 0.40.2

- name: Set up AWS configuration file
run: |
# shellcheck disable=SC2086
sed -i "s/__AWS_ACCESS_KEY_ID__/${{ secrets.AWS_ACCESS_KEY_ID }}/g" ${{ github.workspace }}/.github/aws-config
sed -i "s/__AWS_SECRET_ACCESS_KEY__/${{ secrets.AWS_SECRET_ACCESS_KEY }}/g" ${{ github.workspace }}/.github/aws-config
echo "AWS_CONFIG_FILE=${{ github.workspace }}/.github/aws-config" >> $GITHUB_ENV

- name: Terragrunt run-all init
run: terragrunt run-all init

- name: Terragrunt run-all plan
run: terragrunt run-all plan

- name: Terragrunt run-all apply
if: github.ref == 'refs/heads/main'
run: terragrunt run-all apply

helm:
name: Helm
runs-on: ubuntu-latest
needs: terraform
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 2

- name: Get kubernetes configuration file
run: |
aws eks --region eu-west-3 update-kubeconfig --name aws-eks-irsa

- name: Helm install AWS CLI chart
run: |
helm upgrade \
--install \
--create-namespace \
--namespace aws-eks-irsa \
--set awsAccountId=${{ secrets.AWS_ACCOUNT_ID }} \
aws-cli helm/aws-cli
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ kubectl get pods -n kube-system

You can install the `aws-cli` Helm chart as such (after replacing `<YOUR_AWS_ACCOUNT_ID>` with your account ID):
```bash
helm install --create-namespace --namespace aws-eks-irsa --set awsAccountId=<YOUR_AWS_ACCOUNT_ID> aws-cli helm/aws-cli
helm upgrade --install --create-namespace --namespace aws-eks-irsa --set awsAccountId=<YOUR_AWS_ACCOUNT_ID> aws-cli helm/aws-cli
```

Then, you can check your resources were created into the EKS cluster:
Expand Down