-
Notifications
You must be signed in to change notification settings - Fork 50
76 lines (65 loc) · 2.78 KB
/
main.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
name: Kubernetes deployment
on:
push:
branches: [ dev, main ]
jobs:
build:
name: Building and Pushing Image
if: ${{ !contains(github.event.head_commit.message, '#k8s') }}
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- 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: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push Frontend to Amazon ECR
id: build-frontend-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ github.event.repository.name }}
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git_branch=${GITHUB_REF##*/}
solana_endpoint="https://rpc.mainnet.holaplex.tools"
if [ $git_branch == 'main' ];then
graphql_endpoint="https://graph.holaplex.com/v1"
node_env=production
else
graphql_endpoint="https://graph-test.holaplex.com/v1"
node_env=development
fi
image_tag="$ECR_REGISTRY/$ECR_REPOSITORY:$git_branch-$git_hash"
#build
docker build -t $image_tag \
--build-arg GRAPHQL_URI=${graphql_endpoint} \
--build-arg SOLANA_ENDPOINT=${solana_endpoint} \
--build-arg NEXT_ENVIRONMENT=$node_env \
.
echo "Pushing image to ECR..."
docker push $image_tag
echo "::set-output name=image::$image_tag"
- name: Update deployment image version (dev)
if: github.ref == 'refs/heads/dev'
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git_branch=${GITHUB_REF##*/}
version=$(cat ./k8s/$git_branch/app/marketplace-deploy.yaml | grep -i image | awk {'print $2'} | head -n1 | cut -d: -f2)
sed -i "s/$version/$git_branch-$git_hash/" ./k8s/$git_branch/app/marketplace-deploy.yaml
- name: Update deployment image version (prod)
if: github.ref == 'refs/heads/main'
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
version=$(cat ./k8s/prod/app/marketplace-deploy.yaml | grep -i image | awk {'print $2'} | head -n1 | cut -d: -f2)
sed -i "s/$version/${GITHUB_REF##*/}-$git_hash/" ./k8s/prod/app/marketplace-deploy.yaml
- name: Commit and push changes
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.ACTIONS_TOKEN}}
commit_message: Updated deployment image version