Merge pull request #1477 from bakaphp/feat-task-list #1427
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: Deploy To AWS | |
on: | |
push: | |
branches: | |
- '1.x' | |
- 'development' | |
workflow_dispatch: | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_name }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install AWS CLI | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install --update | |
- name: AWS ECR | |
uses: kciter/aws-ecr-action@v5 | |
with: | |
access_key_id: ${{ secrets.AWS_ACCESS_KEY_CICD }} | |
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }} | |
account_id: 617498580299 | |
repo: ${{ secrets.INSTANCE_NAME }} | |
region: ${{ secrets.AWS_REGION }} | |
create_repo: true | |
tags: latest,${{ github.run_number }}, | |
dockerfile: ${{ github.ref_name }}.Dockerfile | |
Deploy: | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_name }} | |
needs: Build | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: set-vars | |
run: | | |
cat .github/workflows/${GITHUB_REF##*/}-destinations >> $GITHUB_ENV | |
- name: Install Kubernetes toolset | |
uses: stefanprodan/[email protected] | |
with: | |
kubectl: 1.23.0 | |
- name: Download Configmap | |
uses: keithweaver/[email protected] | |
with: | |
command: cp | |
source: ${{ secrets.CONFIGMAP }} | |
destination: helm/templates/envconfigmap.yaml | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_CICD }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }} | |
aws_region: ${{ secrets.AWS_REGION }} | |
- name: Deploy helm chart | |
run: | | |
#configure aws login | |
if rm -rf /home/runner/.aws | |
then | |
echo old credentials removed | |
fi | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_CICD }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_CICD }} | |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.CLUSTER_NAME }} | |
# For now ignore managed-cert file to avoid conflict with gcp | |
touch helm/.helmignore | |
echo "managed-cert.yaml" >> helm/.helmignore | |
echo "svc-gcp-lb.yaml" >> helm/.helmignore | |
echo "ingress-gcp-lb.yaml" >> helm/.helmignore | |
#deploy or upgrade helm chart | |
helm upgrade --install ${{ secrets.INSTANCE_NAME }} helm \ | |
--namespace ${{ secrets.INSTANCE_NAME }} \ | |
--create-namespace \ | |
--set apiImage=${{ secrets.API_IMAGE }}:${{ github.run_number }} \ | |
--set services.loadBalancer.name=${{ secrets.SERVICE_LOADBALANCER }} \ | |
--set services.loadBalancer.lbSSLCert=${{ secrets.LB_SSLCERT }} | |