-
Notifications
You must be signed in to change notification settings - Fork 5
105 lines (88 loc) · 3.44 KB
/
cd-on-pr-create-production.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
name: "Create application production"
on:
pull_request:
branches:
- release/*
push:
tags:
- "v*"
branches:
- release/*
jobs:
build-docker:
# https://github.com/orgs/community/discussions/26281
runs-on: ubuntu-22.04
name: "Build and deploy"
env:
AWS_REGION: us-west-2
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
- name: Preparing merged branches
# Fetch the ref of the base branch, just the single commit.
run: |
git config --global user.email "[email protected]"
git config --global user.name "Zilliqa Bot"
echo "Running git merge --squash ${{ github.head_ref }}"
git merge --squash ${{ github.head_ref }}
echo "Running git checkout main"
git checkout main
git fetch --all --tags
git pull --all
# Checking out the base branch to make this our working branch and
# merge the head
echo "Running git checkout ${{ github.base_ref }}"
git checkout ${{ github.base_ref }}
git fetch --all --tags
git pull --all
- name: Committing head
# Fetch the ref of the base branch, just the single commit.
run: |
echo "Running git merge --squash ${{ github.head_ref }}"
git merge --squash ${{ github.head_ref }} && \
git add . -A && \
git commit -m "Finish merge" || echo "Nothing to merge"
python config/workspace-status.py
- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_SECRET_KEY }}
- name: Bazel cache
id: cache-bazel-debug
uses: actions/[email protected]
with:
path: ~/.cache/bazel/
key: ${{ runner.os }}-bazel-debug
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: "Build and push Docker"
run: |
bazelisk run --test_output=all --keep_going --disk_cache=~/.cache/bazel/ //products/developer-portal:push_image
bazelisk run --test_output=all --keep_going --disk_cache=~/.cache/bazel/ //products/devex:push_image
- name: "Creating Devops repo update for PR"
if: github.event_name == 'pull_request'
run: |
bazelisk run //cd:create_production -- PR $(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
env:
GITHUB_TOKEN: ${{ github.token }}
DEVOPS_ACCESS_TOKEN: ${{ secrets.DEVOPS_ACCESS_TOKEN }}
BUILD_URI_SUFFIX: ${{ github.head_ref }}
- name: "Creating Devops repo update for push and/or tag"
if: github.event_name != 'pull_request'
run: |
bazelisk run //cd:create_production -- HEAD $(git rev-parse --abbrev-ref HEAD)
env:
GITHUB_TOKEN: ${{ github.token }}
DEVOPS_ACCESS_TOKEN: ${{ secrets.DEVOPS_ACCESS_TOKEN }}
BUILD_URI_SUFFIX: ${{ github.ref }}