|
| 1 | +name: Injective list - Generate data |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "*/15 * * * *" |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + generate: |
| 13 | + if: ${{ !contains(github.event.commits[0].message, 'generate json files') }} |
| 14 | + name: "Regenerate JSON files" |
| 15 | + runs-on: blacksmith-8vcpu-ubuntu-2204 |
| 16 | + permissions: write-all |
| 17 | + env: |
| 18 | + ## Github Actions |
| 19 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
| 20 | + CLOUD_FLARE_API_KEY: ${{ secrets.CLOUD_FLARE_API_KEY }} |
| 21 | + CLOUD_FLARE_ACCOUNT_ID: ${{ secrets.CLOUD_FLARE_ACCOUNT_ID }} |
| 22 | + CLOUD_FLARE_ACCOUNT_HASH: ${{ secrets.CLOUD_FLARE_ACCOUNT_HASH }} |
| 23 | + ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }} |
| 24 | + ALCHEMY_GOERLI_KEY: ${{ secrets.ALCHEMY_GOERLI_KEY }} |
| 25 | + ALCHEMY_SEPOLIA_KEY: ${{ secrets.ALCHEMY_SEPOLIA_KEY }} |
| 26 | + MAINNET_FEE_PAYER: ${{ secrets.MAINNET_FEE_PAYER }} |
| 27 | + TESTNET_FEE_PAYER: ${{ secrets.TESTNET_FEE_PAYER }} |
| 28 | + DEVNET_FEE_PAYER: ${{ secrets.DEVNET_FEE_PAYER }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 1 |
| 34 | + token: "${{ secrets.GH_TOKEN }}" |
| 35 | + - run: | |
| 36 | + git reset --hard origin/master |
| 37 | +
|
| 38 | + - name: Install dependencies |
| 39 | + run: cd src && yarn |
| 40 | + |
| 41 | + - name: Generate tokens |
| 42 | + uses: borales/actions-yarn@v4 |
| 43 | + with: |
| 44 | + cmd: generate:tokens |
| 45 | + dir: "src" |
| 46 | + |
| 47 | + - name: Generate validators |
| 48 | + uses: borales/actions-yarn@v4 |
| 49 | + with: |
| 50 | + cmd: generate:validators |
| 51 | + dir: "src" |
| 52 | + |
| 53 | + - name: Generate market slugs |
| 54 | + uses: borales/actions-yarn@v4 |
| 55 | + with: |
| 56 | + cmd: generate:slugs |
| 57 | + dir: "src" |
| 58 | + |
| 59 | + - name: Generate wasm messages |
| 60 | + uses: borales/actions-yarn@v4 |
| 61 | + with: |
| 62 | + cmd: generate:wasm |
| 63 | + dir: "src" |
| 64 | + |
| 65 | + - name: Generate verified denoms |
| 66 | + uses: borales/actions-yarn@v4 |
| 67 | + with: |
| 68 | + cmd: generate:verifiedDenoms |
| 69 | + dir: "src" |
| 70 | + |
| 71 | + - name: Generate restriction list |
| 72 | + uses: borales/actions-yarn@v4 |
| 73 | + with: |
| 74 | + cmd: generate:restriction |
| 75 | + dir: "src" |
| 76 | + |
| 77 | + - name: Generate swap routes |
| 78 | + uses: borales/actions-yarn@v4 |
| 79 | + with: |
| 80 | + cmd: generate:swap:routes |
| 81 | + dir: "src" |
| 82 | + |
| 83 | + - name: Generate configs |
| 84 | + uses: borales/actions-yarn@v4 |
| 85 | + with: |
| 86 | + cmd: generate:configs |
| 87 | + dir: "src" |
| 88 | + |
| 89 | + - name: Commit generated files |
| 90 | + run: | |
| 91 | + [ -z "$(git config user.name)" ] && git config --global user.name "GitHub Actions" |
| 92 | + [ -z "$(git config user.email)" ] && git config --global user.email "[email protected]" |
| 93 | +
|
| 94 | + git add . |
| 95 | +
|
| 96 | + # Check if there are any changes to commit |
| 97 | + if [ -z "$(git status --porcelain)" ]; then |
| 98 | + echo "No changes to commit" |
| 99 | + exit 0 |
| 100 | + fi |
| 101 | +
|
| 102 | + if [[ "${{ contains(github.event.commits[0].message, 'skip deploy') }}" == "true" || "${{ github.event_name != 'push' }}" == "true" ]]; then |
| 103 | + git commit -m "chore: generate json files - skip deploy" --no-verify |
| 104 | + else |
| 105 | + git commit -m "chore: generate json files" --no-verify |
| 106 | + fi |
| 107 | +
|
| 108 | + git push origin HEAD:master |
| 109 | + env: |
| 110 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 111 | + |
| 112 | + # - name: Commit changes |
| 113 | + # uses: EndBug/add-and-commit@v9 |
| 114 | + # if: ${{ github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }} |
| 115 | + # with: |
| 116 | + # message: "chore: generate json files" |
| 117 | + |
| 118 | + # - name: Commit changes |
| 119 | + # uses: EndBug/add-and-commit@v9 |
| 120 | + # if: ${{ github.event_name != 'push' || contains(github.event.commits[0].message, 'skip deploy') }} |
| 121 | + # with: |
| 122 | + # message: "chore: generate json files - skip deploy" |
| 123 | + |
| 124 | + deployAws: |
| 125 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }} |
| 126 | + name: "Deploy AWS" |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: generate |
| 129 | + |
| 130 | + steps: |
| 131 | + - name: Sleep for 30s |
| 132 | + if: ${{ env.SKIP_DEPLOYMENTS != 'true' }} |
| 133 | + uses: juliangruber/[email protected] |
| 134 | + with: |
| 135 | + time: 30s |
| 136 | + # This is here solely for testing and running this action locally with ACT - it shouldn't be needed for running on github as the images in gh actions should already have the AWS CLI installed |
| 137 | + - name: Install Act dependencies |
| 138 | + if: ${{ env.ACT }} |
| 139 | + run: | |
| 140 | + apt-get update && apt-get install sudo -y && apt-get install wget -y && apt-get install unzip -y |
| 141 | +
|
| 142 | + - name: Install AWS if running locally |
| 143 | + if: ${{ env.ACT }} |
| 144 | + uses: unfor19/install-aws-cli-action@v1 |
| 145 | + with: |
| 146 | + version: 2 # default |
| 147 | + verbose: true # default |
| 148 | + arch: amd64 # allowed values: amd64, arm64 |
| 149 | + |
| 150 | + - name: Checkout with retry |
| 151 | + uses: actions/checkout@v4 |
| 152 | + with: |
| 153 | + ref: ${{ github.ref }} |
| 154 | + fetch-depth: 2 |
| 155 | + token: ${{ secrets.GH_TOKEN }} |
| 156 | + |
| 157 | + - name: Setup AWS CLI |
| 158 | + uses: aws-actions/configure-aws-credentials@v4 |
| 159 | + with: |
| 160 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 161 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 162 | + aws-region: us-east-1 |
| 163 | + |
| 164 | + - name: Sync files to S3 bucket |
| 165 | + run: | |
| 166 | + aws s3 sync json s3://injective-lists/json --delete \ |
| 167 | + --cache-control "public, max-age=31536000, s-maxage=31536000" |
| 168 | +
|
| 169 | + - name: Invalidate CloudFront cache |
| 170 | + run: | |
| 171 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
| 172 | +
|
| 173 | + - name: Sleep for 60s |
| 174 | + if: ${{ env.SKIP_DEPLOYMENTS != 'true' }} |
| 175 | + uses: juliangruber/[email protected] |
| 176 | + with: |
| 177 | + time: 60s |
| 178 | + |
| 179 | + - name: Invalidate CloudFront cache |
| 180 | + run: | |
| 181 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
| 182 | +
|
| 183 | + deployAwsStaging: |
| 184 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }} |
| 185 | + name: "Deploy AWS Staging" |
| 186 | + runs-on: ubuntu-latest |
| 187 | + needs: generate |
| 188 | + |
| 189 | + steps: |
| 190 | + - name: Sleep for 30s |
| 191 | + uses: juliangruber/[email protected] |
| 192 | + with: |
| 193 | + time: 30s |
| 194 | + |
| 195 | + - name: Install Act dependencies |
| 196 | + if: ${{ env.ACT }} |
| 197 | + run: | |
| 198 | + apt-get update && apt-get install sudo -y && apt-get install wget -y && apt-get install unzip -y |
| 199 | +
|
| 200 | + - name: Install AWS if running locally |
| 201 | + if: ${{ env.ACT }} |
| 202 | + uses: unfor19/install-aws-cli-action@v1 |
| 203 | + with: |
| 204 | + version: 2 # default |
| 205 | + verbose: true # default |
| 206 | + arch: amd64 # allowed values: amd64, arm64 |
| 207 | + |
| 208 | + - name: Checkout with retry |
| 209 | + uses: actions/checkout@v4 |
| 210 | + with: |
| 211 | + ref: ${{ github.ref }} |
| 212 | + fetch-depth: 2 |
| 213 | + token: ${{ secrets.GH_TOKEN }} |
| 214 | + |
| 215 | + - name: Setup AWS CLI |
| 216 | + uses: aws-actions/configure-aws-credentials@v4 |
| 217 | + with: |
| 218 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 219 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 220 | + aws-region: us-east-2 |
| 221 | + |
| 222 | + - name: Sync files to S3 bucket |
| 223 | + run: | |
| 224 | + aws s3 sync json s3://injective-lists/json --delete \ |
| 225 | + --cache-control "public, max-age=31536000, s-maxage=31536000" |
| 226 | +
|
| 227 | + - name: Invalidate CloudFront cache |
| 228 | + run: | |
| 229 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
| 230 | +
|
| 231 | + - name: Sleep for 60s |
| 232 | + uses: juliangruber/[email protected] |
| 233 | + with: |
| 234 | + time: 60s |
| 235 | + |
| 236 | + - name: Invalidate CloudFront cache |
| 237 | + run: | |
| 238 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
0 commit comments