-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (87 loc) · 3.74 KB
/
Copy pathdeploy-develop.yml
File metadata and controls
99 lines (87 loc) · 3.74 KB
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
name: Deploy Develop
on:
push:
branches: [develop]
jobs:
retrieveTestCoverage:
name: Retrieve Develop test coverage
runs-on: ubuntu-latest
steps:
- name: Get test coverage artifact download URL
run: |
artifact_url=$(curl --request GET --url https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' --header 'Accept: application/vnd.github.v3+json' | jq -r '[.artifacts[] | select(.name == "develop-test-coverage")] | sort_by(.updated_at)[-1].archive_download_url');
echo "##[set-output name=latest;]$artifact_url"
id: artifact_url
- name: Get test coverage artifact
run: "curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -o develop-test-coverage.zip -JL ${{ steps.artifact_url.outputs.latest }} && unzip develop-test-coverage.zip -d coverage"
- name: Upload the Develop Test Coverage as an Artifact
uses: actions/upload-artifact@v2
with:
name: develop-test-coverage
path: coverage/coverage-develop.html
retention-days: 7
buildContainer:
name: Build API and Push Container to Registry
runs-on: ubuntu-latest
needs: retrieveTestCoverage
env:
API_CONTAINER_NAME: rm-elixir-api-develop
COMPOSE_FILE: .ci/docker-compose.yml
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get develop test coverage artifact
uses: actions/download-artifact@master
with:
name: develop-test-coverage
path: priv/static/cover
- name: Rename develop test coverage artifact
run: sudo mv priv/static/cover/coverage-develop.html priv/static/cover/excoveralls.html
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.DEV_AWS_DEFAULT_REGION }}
role-duration-seconds: 1200
role-session-name: aws-session-develop-ci
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
id: login-ecr
# Pull the latest image to build, and avoid caching pull-only images.
# (docker pull is faster than caching in most cases.)
- name: Pull docker images
run: docker-compose pull release
env:
ELIXIR_VERSION: ${{ secrets.ELIXIR_VERSION }}
IMAGE_TAG: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_NAME }}:dev-latest
# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- name: Cache docker layers
uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
with:
key: ${GITHUB_REF##*/}-cache-{hash}
restore-keys: |
${GITHUB_REF##*/}-cache-
- name: Build API Container
run: |
docker-compose build release;
docker push $IMAGE_TAG;
env:
ELIXIR_VERSION: ${{ secrets.ELIXIR_VERSION }}
IMAGE_TAG: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_NAME }}:dev-latest
release:
name: Deploy latest to Develop
runs-on: ubuntu-latest
needs: buildContainer
steps:
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BASTION_HOST }}
username: ${{ secrets.BASTION_USER }}
key: ${{ secrets.KEY_DEV }}
script: /usr/local/bin/deploy-dispatch api