Merge pull request #18 from fetchoracle/update-team-email #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Image Builder' | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- '*' | |
permissions: | |
contents: read | |
env: | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
jobs: | |
test: | |
name: 'Tests' | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ${{ github.workspace }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ${{ env.working-directory }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref_name }} | |
submodules: recursive | |
token: ${{ secrets.TOKEN_GITHUB }} | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Install Dependencies | |
run: | | |
sh install.sh | |
mv ./telliot-feeds/telliot-core ../ | |
mv ./telliot-feeds ../ | |
npm install -g ganache | |
- name: Start Test Dependencies | |
run: | | |
ganache-cli --detach | |
- name: Run tests | |
run: pytest | |
- name: Obtain Commit SHA | |
if: always() | |
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: Send Slack Notification | |
uses: slackapi/slack-github-action@v1.19.0 | |
if: always() | |
with: | |
channel-id: 'devops-build-notification' | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "GitHub Action ${{github.repository}} result: *${{ job.status }}*" | |
} | |
}, | |
{ | |
"type": "section", | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*REPO:*\n${{github.repository}}" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*JOB NAME:*\nTest dvm" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*COMMIT:*\n<${{ github.event.pull_request.html_url || github.event.head_commit.url }}|${{env.SHORT_SHA}}>" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*Author:*\n${{github.actor}}" | |
} | |
] | |
} | |
] | |
} | |
publish: | |
name: 'Image Builder' | |
runs-on: ubuntu-latest | |
needs: test | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
working-directory: ${{ github.workspace }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ${{ env.working-directory }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref_name }} | |
submodules: recursive | |
token: ${{ secrets.TOKEN_GITHUB }} | |
- name: Add profile credentials to ~/.aws/credentials | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile fetchoracle-dev | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile fetchoracle-dev | |
- name: Build Image | |
run: docker buildx build --platform=linux/amd64 -t dvm . --no-cache | |
- name: Publish Image to ECR | |
run: | | |
TAG=${{ github.ref }} | |
TAG=${TAG#refs/tags/} | |
echo "Tag value: $TAG" | |
aws ecr get-login-password --region ap-southeast-2 --profile fetchoracle-dev | docker login --username AWS --password-stdin 090838539286.dkr.ecr.ap-southeast-2.amazonaws.com | |
docker tag dvm:latest 090838539286.dkr.ecr.ap-southeast-2.amazonaws.com/dvm:$TAG | |
docker push 090838539286.dkr.ecr.ap-southeast-2.amazonaws.com/dvm:$TAG | |
- name: Obtain Commit SHA | |
if: always() | |
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: Send Slack Notification | |
uses: slackapi/slack-github-action@v1.19.0 | |
if: always() | |
with: | |
channel-id: 'devops-build-notification' | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "GitHub Action ${{github.repository}} result: *${{ job.status }}*" | |
} | |
}, | |
{ | |
"type": "section", | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*REPO:*\n${{github.repository}}" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*JOB NAME:*\nPublish Image" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*COMMIT:*\n<${{ github.event.pull_request.html_url || github.event.head_commit.url }}|${{env.SHORT_SHA}}>" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*Author:*\n${{github.actor}}" | |
} | |
] | |
} | |
] | |
} |