-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (81 loc) · 2.92 KB
/
build_push.yaml
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
name: CI Pipeline Push
on:
push:
branches: [ main, development ]
env:
REPOSITORY_NAME: book-recommendations-v2
jobs:
build:
name: Setup and Mirror to AWS CodeBuild
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
AWS_REGION: us-east-1
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Lint and Unit Tests for API Gateway
working-directory: api-gateway/
run: |
make build
make lint-app
make test-app
- name: Lint and Unit Tests for Users Microservice
working-directory: users-microservice/
run: |
make build
make lint-app
make test-app
- name: Lint and Unit Tests for Books Microservice
working-directory: books-microservice/
run: |
make build
make lint-app
make test-app
- name: Lint and Unit Tests for Recommendations Microservice
working-directory: recommendations-microservice/
run: |
make build
make lint-app
make test-app
- name: Build and push Docker images
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
working-directory: infrastructure/terraform/
run: |
IMAGE_VERSION=$(git rev-parse --short=7 HEAD) make push-image
- name: Retrieve private SSH file to Git Authentication through SSH
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 cp s3://${{ secrets.S3_BUCKET_NAME }}/book-recommendations/book-recommendations /tmp/book-recommendations
chmod 600 /tmp/book-recommendations
- name: Set SSH config file
run: |
mkdir -p ~/.ssh
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
ssh-keyscan -t rsa git-codecommit.${AWS_REGION}.amazonaws.com >> ~/.ssh/known_hosts
echo "Host git-codecommit.*.amazonaws.com" >> ~/.ssh/config
echo "User ${{ secrets.CODE_COMMIT_SSH_KEY_ID }}" >> ~/.ssh/config
echo "IdentityFile /tmp/book-recommendations" >> ~/.ssh/config
chmod 600 ~/.ssh/config
- name: Mirror to AWS CodeCommit
run: |
git remote add codecommit ssh://git-codecommit.${AWS_REGION}.amazonaws.com/v1/repos/${REPOSITORY_NAME}
git remote update codecommit
# git fetch --unshallow codecommit || true
# git pull --prune
git push -f codecommit $GITHUB_REF_NAME
# git push --mirror ssh://git-codecommit.${AWS_REGION}.amazonaws.com/v1/repos/${REPOSITORY_NAME}
- name: Remove temp files
run: |
rm -rf ~/.ssh/config /tmp/book-recommendations ~/.docker/config.json
- name: Print job status
run: |
echo "JOB STATUS ${{ job.status }}"