This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
77 lines (70 loc) · 3.12 KB
/
deploy.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
name: deploy
on:
workflow_dispatch:
inputs:
commit:
description: Commit SHA to deploy. Default to main branch's commit.
environment:
type: choice
options:
- rpc-gateway-arbitrum
- rpc-gateway-avalanche
- rpc-gateway-bsc
- rpc-gateway-celo
- rpc-gateway-ethereum
- rpc-gateway-ethereum-staging
- rpc-gateway-fantom
- rpc-gateway-optimism
- rpc-gateway-polygon
required: true
env:
IMAGE_NAME: 883408475785.dkr.ecr.us-east-1.amazonaws.com/rpc-gateway
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Validate Input
id: validate_input
uses: actions/github-script@v7
with:
script: |
const { environment, commit } = context.payload.inputs
core.setOutput('environment', environment)
core.setOutput('commit', commit ? commit : context.sha)
- uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
state: closed
- name: Checkout 0x-main-infra repo
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
repository: 0xProject/0x-main-infra
- name: Update GitOps repo
id: update_gitops_repo
run: |
cd 'clusters/main-cluster/kubernetes/${{ steps.validate_input.outputs.environment }}'
# Read current image tag
current_image_tag=$(yq e '.images[] | select(.name | contains("rpc-gateway")) | .newTag' kustomization.yaml)
# Update image tags
kustomize edit set image ${IMAGE_NAME}:${{ steps.validate_input.outputs.commit }}
# Output for next steps
echo "##[set-output name=current_image_tag;]${current_image_tag}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
author: ${{ github.event.sender.login }} <${{ github.event.sender.login }}@users.noreply.github.com>
commit-message: 'rpc-gateway deploy to ${{ steps.validate_input.outputs.environment }}: ${{ steps.validate_input.outputs.commit }}'
title: '[rpc-gateway][deploy][${{ steps.validate_input.outputs.environment }}] Revision ${{ steps.validate_input.outputs.commit }}'
branch: 'rpc-gateway/deploy/${{ steps.validate_input.outputs.environment }}'
body: |
### Deployment Details
Triggered by @${{ github.event.sender.login }}
PR: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.number }}
**Current version:** https://github.com/${{ github.repository }}/commit/${{ steps.update_gitops_repo.outputs.current_image_tag }}
**Target version:** https://github.com/${{ github.repository }}/commit/${{ steps.validate_input.outputs.commit }}
Comparison: https://github.com/${{ github.repository }}/compare/${{ steps.update_gitops_repo.outputs.current_image_tag }}...${{ steps.validate_input.outputs.commit }}
- name: Check outputs
run: |
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"