-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (80 loc) · 2.88 KB
/
test-deploy-publish.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
name: Test, Deploy, Publish
on:
push:
branches: ["**"]
tags: ['v[0-9]+.[0-9]+.[0-9]+']
paths-ignore:
- 'terraform/**'
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ vars.AWS_REGION }}
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test
run: docker compose -f actions-services.yml run --rm test ./scripts/test.sh
deploy:
name: Deploy to AWS Lambda
needs: tests
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ vars.AWS_REGION }}
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
STG_LAMBDA_ROLE: ${{ vars.STG_LAMBDA_ROLE }}
STG_API_KEY_TABLE: ${{ vars.STG_API_KEY_TABLE }}
STG_WEBAUTHN_TABLE: ${{ vars.STG_WEBAUTHN_TABLE }}
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
PRD_LAMBDA_ROLE: ${{ vars.PRD_LAMBDA_ROLE }}
PRD_API_KEY_TABLE: ${{ vars.PRD_API_KEY_TABLE }}
PRD_WEBAUTHN_TABLE: ${{ vars.PRD_WEBAUTHN_TABLE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy
run: docker compose -f actions-services.yml run --rm app ./scripts/deploy.sh
build-and-publish:
name: Build and Publish
needs: tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor}}
password: ${{ secrets.GITHUB_TOKEN}}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}},enable=true
type=semver,pattern={{major.minor}},enable=true
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}