Skip to content

Merge pull request #106 from zippiehq/AIR-1505-fe-fix-tosi-scan-asset… #180

Merge pull request #106 from zippiehq/AIR-1505-fe-fix-tosi-scan-asset…

Merge pull request #106 from zippiehq/AIR-1505-fe-fix-tosi-scan-asset… #180

Workflow file for this run

name: Tosiscan build and deploy workflow
on:
push:
branches:
- main
- test
paths:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Dump Contexts
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: |
echo "$GITHUB_CONTEXT"
echo "$RUNNER_CONTEXT"
# git context is the default for actions but this will fail for docker in
# a monorepo with multiple (docker) build contexts. As such, we must
# checkout...
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx--${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx--
- name: Build
uses: docker/build-push-action@v3
env:
REACT_APP_DATACHAIN_BASE_URL: "https://tosiscan-testnet-one.zippie.com"
with:
context: .
file: Dockerfile
load: true # persist the image so later step(s) can call it
tags: ${{github.event.repository.name}}:${{github.sha}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- # Currently there is no way to cleanly export a docker image between
# jobs so instead we package a tarball so that subsequent jobs can
# download it.
name: Package
run: |
rm -rf /tmp/${{github.sha}}
mkdir /tmp/${{github.sha}}
docker create --name=${{github.sha}} \
${{github.event.repository.name}}:${{github.sha}}
docker cp ${{github.sha}}:/app//build /tmp/${{github.sha}}/
echo ${{github.sha}} > /tmp/${{github.sha}}/build/version.txt
cd /tmp && tar cfJ /tmp/${{github.sha}}.txz ${{github.sha}}
- name: Intermediate Artifact Upload
uses: actions/upload-artifact@v3
with:
name: ${{github.sha}}
path: /tmp/${{github.sha}}.txz
retention-days: 15
- # 'Temporary' cleanup fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Docker Cache Management
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: always()
env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK_CIBOT}}
SLACK_CHANNEL: cibot
SLACK_COLOR: ${{job.status}}
SLACK_USERNAME: Zippie Actions
SLACK_TITLE: '${{github.repository}}: ${{github.job}}: ${{github.ref}} event triggered workflow run ${{github.run_number}}'
SLACK_MESSAGE: 'Build ${{job.status}}: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}'
SLACK_FOOTER: commit ${{github.sha}}
SLACK_ICON_EMOJI: ':beers:'
MSG_MINIMAL: true
deploydev:
if: github.ref == 'refs/heads/main'
env:
BUCKET: z-dev-tosiscan
runs-on: ubuntu-latest
needs: build
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
- name: Intermediate Artifact Download
uses: actions/download-artifact@v2
with:
name: ${{github.sha}}
path: /tmp/
- name: s3 sync
run: |
echo "Bucket is set to ${BUCKET}"
cd /tmp
tar xfvJ /tmp/${{github.sha}}.txz
cd /tmp/${{github.sha}}/build
aws s3 sync --delete . s3://${BUCKET}/public/
# NOTE! awscliv2 syntax
# NOTE! metadata permissions differ between environments
aws s3 cp s3://${BUCKET}/public s3://${BUCKET}/public \
--exclude '*' \
--include '*.html' \
--include '*.css' \
--include '*.js' \
--include '*.json' \
--cache-control 'no-store, must-revalidate' \
--copy-props 'metadata-directive' \
--recursive
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: always()
env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK_CIBOT}}
SLACK_CHANNEL: cibot
SLACK_COLOR: ${{job.status}}
SLACK_USERNAME: Zippie Actions
SLACK_TITLE: '${{github.repository}}: ${{github.job}}: ${{github.job.status}}'
SLACK_MESSAGE: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}'
SLACK_FOOTER: commit ${{github.sha}}
SLACK_ICON_EMOJI: ':beers:'
MSG_MINIMAL: true
deploytest:
if: github.ref == 'refs/heads/test'
env:
BUCKET: z-test-tosiscan
runs-on: ubuntu-latest
needs: build
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
- name: Intermediate Artifact Download
uses: actions/download-artifact@v2
with:
name: ${{github.sha}}
path: /tmp/
- name: s3 sync
run: |
cd /tmp &&
tar xfJ /tmp/${{github.sha}}.txz &&
cd /tmp/${{github.sha}}/build &&
aws s3 sync --delete . s3://${BUCKET}/public/
# NOTE! awscliv2 syntax
# NOTE! metadata permissions differ between environments
aws s3 cp s3://${BUCKET}/public s3://${BUCKET}/public \
--exclude '*' \
--include '*.html' \
--include '*.css' \
--include '*.js' \
--include '*.json' \
--cache-control 'max-age=300, must-revalidate' \
--copy-props 'metadata-directive' \
--recursive
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: always()
env:
SLACK_WEBHOOK: ${{secrets.SLACK_WEBHOOK_CIBOT}}
SLACK_CHANNEL: cibot
SLACK_COLOR: ${{job.status}}
SLACK_USERNAME: Zippie Actions
SLACK_TITLE: '${{github.repository}}: ${{github.job}}: ${{github.job.status}}'
SLACK_MESSAGE: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}'
SLACK_FOOTER: commit ${{github.sha}}
SLACK_ICON_EMOJI: ':beers:'
MSG_MINIMAL: true