forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 12
152 lines (150 loc) · 6.47 KB
/
ci-build.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: "Flujo CI-Build"
run-name: "Flujo CI - Build"
on:
workflow_dispatch:
inputs:
cloud:
description: "Proveedor Cloud"
required: true
default: "AWS"
options: ["AWS", "GCP", "Azure"]
issue_comment:
types: [created]
jobs:
docker-aws:
if: |
(github.event.issue.pull_request && contains(github.event.comment.body, 'Build-AWS')) ||
github.event.inputs.cloud == 'AWS'
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar QEMU"
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 #v2: v2.1.0
- name: "Configurar Docker Buildx"
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c #v2: v2.5.0
- name: "Configurar tag y etiquetas para ${{ github.ref }}"
run: |
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=snapshot" >> $GITHUB_ENV
fi
echo "VCS_REF=`git rev-parse --short HEAD`" >> $GITHUB_ENV
echo "BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”`" >> $GITHUB_ENV
- 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: "Autenticar en AWS ECR"
id: login-ecr-publico
uses: aws-actions/amazon-ecr-login@261a7de32bda11ba01f4d75c4ed6caf3739e54be #v1 #v1.5.3
with:
registry-type: public
- name: "Compilar y Subir imagen de Docker"
env:
REGISTRY: ${{ steps.login-ecr-publico.outputs.registry }}
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 #v4 #v4.0.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ vars.AWS_REGISTRY_ALIAS }}/${{ vars.AWS_REPOSITORY }}:${{ env.DOCKER_TAG }}
build-args: |
VCS_REF=${{ env.VCS_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
docker-gcp:
if: |
(github.event.issue.pull_request && contains(github.event.comment.body, 'Build-GCP')) ||
github.event.inputs.cloud == 'GCP'
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar QEMU"
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 #v2: v2.1.0
- name: "Configurar Docker Buildx"
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c #v2: v2.5.0
- name: "Configurar tag y etiquetas para ${{ github.ref }}"
run: |
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=snapshot" >> $GITHUB_ENV
fi
echo "VCS_REF=`git rev-parse --short HEAD`" >> $GITHUB_ENV
echo "BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”`" >> $GITHUB_ENV
- 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: "Compilar y Subir imagen de Docker"
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 #v4 #v4.0.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ vars.GCP_REGION }}-${{ vars.GCP.REGISTRY}}/${{ vars.GCP_PROJECT_ID }}/${{ vars.GCP_REPOSITORY_NAME }}/${{ vars.GCP_IMAGE_NAME }}:${{ env.DOCKER_TAG }}
build-args: |
VCS_REF=${{ env.VCS_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
docker-azure:
if: |
(github.event.issue.pull_request && contains(github.event.comment.body, 'Build-Azure')) ||
github.event.inputs.cloud == 'Azure'
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar QEMU"
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 #v2: v2.1.0
- name: "Configurar Docker Buildx"
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c #v2: v2.5.0
- name: "Configurar tag y etiquetas para ${{ github.ref }}"
run: |
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=snapshot" >> $GITHUB_ENV
fi
echo "VCS_REF=`git rev-parse --short HEAD`" >> $GITHUB_ENV
echo "BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”`" >> $GITHUB_ENV
- name: "Autenticar en Azure"
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 #v1 #v1.4.6
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: "Autenticar en Azure Container Registry"
uses: azure/docker-login@83efeb77770c98b620c73055fbb59b2847e17dc0 #v1 #v1.0.1
with:
login-server: ${{ vars.AZURE_REGISTRY_NAME }}
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
- name: "Compilar y Subir imagen de Docker"
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 #v4 #v4.0.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ vars.AZURE_REGISTRY_NAME }}/${{ vars.AZURE_IMAGE_NAME }}:${{ env.DOCKER_TAG }}
build-args: |
VCS_REF=${{ env.VCS_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}