forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 12
83 lines (81 loc) · 3.26 KB
/
cd.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: "Flujo CD"
run-name: "Flujo CD"
on:
workflow_dispatch:
inputs:
cloud:
description: "Proveedor Cloud"
required: true
default: "AWS"
options: ["AWS", "GCP", "Azure"]
jobs:
aws:
runs-on: ubuntu-latest
if: github.event.inputs.cloud == 'AWS'
steps:
- name: "Configurar credenciales de AWS"
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef #v2 #v2.0.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Crear archivo de configuración para AppRunner
run: |
echo '{
"ServiceArn": "${{ vars.AWS_APPRUNNER_ARN}}",
"SourceConfiguration": {
"ImageRepository": {
"ImageIdentifier": "${{ vars.AWS_REGISTRY }}/${{ vars.AWS_REGISTRY_ALIAS }}/${{ vars.AWS_REPOSITORY }}:latest",
"ImageRepositoryType": "ECR_PUBLIC"
}
}
}' > apprunner.json
- name: Actualizar app en AWS App Runner
run: |
aws apprunner update-service \
--cli-input-json file://apprunner.json
gcp:
runs-on: ubuntu-latest
if: github.event.inputs.cloud == 'GCP'
env:
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
SERVICE_NAME: ${{ vars.GCP_SERVICE_NAME }}
REGION: ${{ vars.GCP_REGION }}
steps:
- name: "Autenticar en GCP"
id: auth
uses: google-github-actions/auth@ef5d53e30bbcd8d0836f4288f5e50ff3e086997d #v1.0.0
with:
token_format: access_token
workload_identity_provider: ${{ env.PROJECT_ID }}
service_account: ${{ secrets.GCP_SA_KEY }}
- name: "Autenticar en Artifact Registry"
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2 #v2.1.0
with:
registry: ${{ vars.GCP.REGISTRY}}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: "Desplegar en Cloud Run"
uses: google-github-actions/deploy-cloudrun@9c01af28be5da14b228ba369b7700d22830b35b7 #v1.0.1
with:
image: ${{ vars.GCP_REGION }}-${{ vars.GCP.REGISTRY}}/${{ vars.GCP_PROJECT_ID }}/${{ vars.GCP_REPOSITORY_NAME }}/${{ vars.GCP_IMAGE_NAME }}:latest
region: ${{ env.REGION }}
service: ${{ env.SERVICE_NAME }}
azure:
runs-on: ubuntu-latest
if: github.event.inputs.cloud == 'Azure'
steps:
- name: "Autenticar en Azure"
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 #v1 #v1.4.6
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: "Crear Azure Container Instance"
uses: Azure/aci-deploy@28cafb864979bc5b44cd1f3fd45522727eb5a3db #v1 #v1.1.3
with:
resource-group: ${{ vars.AZURE_RESOURCE_NAME }}
name: ${{ VARS.AZURE_CONTAINER_INSTANCE_NAME}}
dns-name-label: ${{ vars.AZURE_DNS }}
image: ${{ vars.AZURE_REGISTRY_NAME }}/${{ vars.AZURE_IMAGE_NAME }}:latest
registry-username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
registry-password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
location: ${{ vars.AZURE_REGION }}