From b8ff2995aa43fc4524ac9e38c36c27dd80bb0d4f Mon Sep 17 00:00:00 2001
From: Juan Manuel Rodriguez Defago <juanma.rdefago@gmail.com>
Date: Wed, 7 Dec 2022 14:34:04 -0300
Subject: [PATCH] feat: refactor workflows

---
 .../deploy-goerli-arbitrum-subgraph.yml       | 20 ++++++++++++++++++
 .../deploy-production-arbitrum-subgraph.yaml  | 20 ++++++++++++++++++
 .../workflows/deploy-production-subgraph.yaml |  2 +-
 .../deploy-staging-arbitrum-subgraph.yaml     | 20 ++++++++++++++++++
 .github/workflows/template-deploy.yaml        | 21 ++++++++++++-------
 5 files changed, 74 insertions(+), 9 deletions(-)
 create mode 100644 .github/workflows/deploy-goerli-arbitrum-subgraph.yml
 create mode 100644 .github/workflows/deploy-production-arbitrum-subgraph.yaml
 create mode 100644 .github/workflows/deploy-staging-arbitrum-subgraph.yaml

diff --git a/.github/workflows/deploy-goerli-arbitrum-subgraph.yml b/.github/workflows/deploy-goerli-arbitrum-subgraph.yml
new file mode 100644
index 00000000..c8e25e5a
--- /dev/null
+++ b/.github/workflows/deploy-goerli-arbitrum-subgraph.yml
@@ -0,0 +1,20 @@
+name: Production Subgraph (Arbitrum Goerli)
+
+on:
+  push:
+    tags:
+      - v*
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: false
+
+jobs:
+  deploy:
+    uses: graphprotocol/graph-network-subgraph/.github/workflows/template-deploy.yaml@master
+    with:
+      ENVIRONMENT: production-arbitrum-goerli
+      CONFIG: arbitrumGoerliAddressScript.ts
+    secrets:
+      NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
+      ACCESS_TOKEN: ${{ secrets.access_token }}
diff --git a/.github/workflows/deploy-production-arbitrum-subgraph.yaml b/.github/workflows/deploy-production-arbitrum-subgraph.yaml
new file mode 100644
index 00000000..ceda8116
--- /dev/null
+++ b/.github/workflows/deploy-production-arbitrum-subgraph.yaml
@@ -0,0 +1,20 @@
+name: Production Subgraph (Arbitrum)
+
+on:
+  push:
+    tags:
+      - v*
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: false
+
+jobs:
+  deploy:
+    uses: graphprotocol/graph-network-subgraph/.github/workflows/template-deploy.yaml@master
+    with:
+      ENVIRONMENT: production-arbitrum
+      CONFIG: mainnetArbitrumAddressScript.ts
+    secrets:
+      NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
+      ACCESS_TOKEN: ${{ secrets.access_token }}
diff --git a/.github/workflows/deploy-production-subgraph.yaml b/.github/workflows/deploy-production-subgraph.yaml
index 01792118..2bece1ee 100644
--- a/.github/workflows/deploy-production-subgraph.yaml
+++ b/.github/workflows/deploy-production-subgraph.yaml
@@ -1,4 +1,4 @@
-name: Production Subgraph (Goerli)
+name: Production Subgraph (Mainnet)
 
 on:
   push:
diff --git a/.github/workflows/deploy-staging-arbitrum-subgraph.yaml b/.github/workflows/deploy-staging-arbitrum-subgraph.yaml
new file mode 100644
index 00000000..1bb28541
--- /dev/null
+++ b/.github/workflows/deploy-staging-arbitrum-subgraph.yaml
@@ -0,0 +1,20 @@
+name: Staging Subgraph (Arbitrum)
+
+on:
+  push:
+    branches:
+      - mainnet-staging
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: false
+
+jobs:
+  deploy:
+    uses: graphprotocol/graph-network-subgraph/.github/workflows/template-deploy.yaml@master
+    with:
+      ENVIRONMENT: staging-arbitrum
+      CONFIG: mainnetArbitrumAddressScript.ts
+    secrets:
+      NODE_AUTH_TOKEN: ${{ secrets.graphprotocol_npm_token }}
+      ACCESS_TOKEN: ${{ secrets.access_token }}
diff --git a/.github/workflows/template-deploy.yaml b/.github/workflows/template-deploy.yaml
index f65a65a3..68d0b5cd 100644
--- a/.github/workflows/template-deploy.yaml
+++ b/.github/workflows/template-deploy.yaml
@@ -22,31 +22,36 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-      - name: Set staging environment variables
-        if: ${{ inputs.ENVIRONMENT == 'staging' }}
+      - name: Set arbitrum staging environment variables
+        if: ${{ inputs.ENVIRONMENT == 'staging-arbitrum' }}
         run: |
-          echo "ENV_SUFFIX=-staging" >> $GITHUB_ENV
+          echo "ENV_SUFFIX=-arbitrum-staging" >> $GITHUB_ENV
 
       - name: Set mainnet staging environment variables
         if: ${{ inputs.ENVIRONMENT == 'staging-mainnet' }}
         run: |
           echo "ENV_SUFFIX=-mainnet-staging" >> $GITHUB_ENV
 
-      - name: Set testnet environment variables
-        if: ${{ inputs.ENVIRONMENT == 'testnet' }}
-        run: |
-          echo "ENV_SUFFIX=-testnet" >> $GITHUB_ENV
-
       - name: Set mainnet environment variables
         if: ${{ inputs.ENVIRONMENT == 'production' }}
         run: |
           echo "ENV_SUFFIX=-mainnet" >> $GITHUB_ENV
 
+      - name: Set arbitrum environment variables
+        if: ${{ inputs.ENVIRONMENT == 'production-arbitrum' }}
+        run: |
+          echo "ENV_SUFFIX=-arbitrum" >> $GITHUB_ENV
+
       - name: Set goerli production environment variables
         if: ${{ inputs.ENVIRONMENT == 'production-goerli' }}
         run: |
           echo "ENV_SUFFIX=-goerli" >> $GITHUB_ENV
 
+      - name: Set arbitrum goerli production environment variables
+        if: ${{ inputs.ENVIRONMENT == 'production-arbitrum-goerli' }}
+        run: |
+          echo "ENV_SUFFIX=-arbitrum-goerli" >> $GITHUB_ENV
+
       - name: Checkout
         uses: actions/checkout@v3