Skip to content

Commit

Permalink
chore: update ci only push to testnets / mainnet on release
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Jun 30, 2022
1 parent 33fe9cf commit eab0d45
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 300 deletions.
117 changes: 0 additions & 117 deletions .github/workflows/push-main-dockerhub.yml

This file was deleted.

144 changes: 63 additions & 81 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -1,118 +1,100 @@
name: push-main
name: push-main-dockerhub

# 1. Run unit and integration tests
# 2. Push containers to AWS ECR with tag based on incrementing build number
# 2. Push containers to dockerhub with tag based on incrementing build number
# 3. Recommit an update to the chart's deployments with the updated build number in the `deployment` branch

on:
push:
branches:
- main
paths-ignore:
- 'chart/**'

jobs:

build:
name: Build containers
docker:
runs-on: ubuntu-latest
env:
NETWORK_NAME: mainnet
DEPLOYMENT_ENVIRONMENT: dev
outputs:
tag: ${{ steps.source.outputs.TAG }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
- id: last
uses: pozetroninc/github-action-get-latest-release@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
repository: ${{ github.repository }}

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: icon-explorer-frontend
IMAGE_TAG: dev-${{ github.run_number }}
- name: Tag name
id: source
run: |
docker build --target prod --build-arg REACT_APP_NETWORK_NAME=$NETWORK_NAME --build-arg REACT_APP_DEPLOYMENT_ENVIRONMENT=$DEPLOYMENT_ENVIRONMENT -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo ::set-output name=TAG::${{ steps.last.outputs.release }}-${{ github.run_number }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

update-values:
name: Update values files
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
target: prod
push: true
tags: sudoblock/icon-tracker-frontend:latest, sudoblock/icon-tracker-frontend:${{ steps.source.outputs.TAG }}

push_refs:
runs-on: ubuntu-latest
needs: build
needs: docker
strategy:
max-parallel: 1
matrix:
include:
# Only push to testnets
- cluster: prod-sng
network_name: sejong
network_version: v2
- cluster: prod-sng
network_name: lisbon
network_version: v2
- cluster: prod-sng
network_name: berlin
network_version: v2
- cluster: prod-ams
network_name: sejong
network_version: v2
- cluster: prod-ams
network_name: lisbon
network_version: v2
- cluster: prod-ams
network_name: berlin
network_version: v2

steps:
- name: Checkout charts repo
uses: actions/checkout@v2
with:
repository: geometry-labs/icon-charts
repository: sudoblockio/icon-charts
ref: main
path: charts
token: ${{ secrets.ICON_CHARTS_PAT }}

- name: Update prod-berlin-us-west-2 deployment values file
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/berlin/tracker-frontend/values.yaml'
propertyPath: 'deployment.image.tag'
value: dev-${{ github.run_number }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false

- name: Update prod-lisbon-us-west-2 deployment values file
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/lisbon/tracker-frontend/values.yaml'
propertyPath: 'deployment.image.tag'
value: dev-${{ github.run_number }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Git pull the latest
run: |
git pull
working-directory: charts

- name: Update dev-mainnet deployment values file and re-commit
- name: Update ${{ matrix.cluster }}/${{ matrix.network_name }}-${{ matrix.network_version }} image tags file
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/dev/mainnet/tracker-frontend/values.yaml'
repository: sudoblockio/icon-charts
valueFile: 'deployments/${{ matrix.cluster }}/${{ matrix.network_name }}-${{ matrix.network_version }}/tracker-frontend/tags.yaml'
propertyPath: 'deployment.image.tag'
value: dev-${{ github.run_number }}
value: ${{needs.docker.outputs.tag}}
branch: main
createPR: 'false'
message: 'tracker-frontend dev deployment (mainnet) image version to ${{ github.run_number }}'
# token: ${{ secrets.ICON_CHARTS_PAT }}
# updateFile: true
updateFile: true
commitChange: false

- name: Configure credentials
uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
message: "tracker frontend ${{ matrix.cluster }}/${{ matrix.network_name }}-${{ matrix.network_version }} deployment image version to ${{needs.docker.outputs.tag}}"
token: '${{ secrets.ICON_CHARTS_PAT }}'
global: true

- name: Commit all updates
run: |
git add -A
git commit -m "tracker-frontend dev and testnet deployment image versions to ${{ github.run_number }}"
git push origin
working-directory: charts

- name: Push tags
run: |
git tag -f tracker-frontend-prod-uswest2
git push -f origin --tags
working-directory: charts
Loading

0 comments on commit eab0d45

Please sign in to comment.