optimizes how components are updated when setting the status to "canc… #575
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: web - build & push image | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'web/**' | |
- .github/workflows/web-main.yaml | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'web/**' | |
- .github/workflows/web-main.yaml | |
env: | |
image_name: zlifecycle-web | |
jobs: | |
build-test-push: | |
name: Build, test, and push | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- uses: actions/checkout@v2 | |
- run: env | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@e5622373a38e60fb6d795a4421e56882f2d7a681 | |
with: | |
images: ${{ steps.login-ecr.outputs.registry }}/${{ env.image_name }} | |
# applies the following image tags (does not apply or use git tags): | |
# PR's: 175-pr-3 [build number]-pr-[pr-number] | |
# push to main applies 2 tags: 176 & 176-abc1234 [build-numner] & [build-number]-sha | |
tags: | | |
type=ref,prefix=${{ github.run_number }}-pr-,event=pr | |
type=sha,prefix=${{ github.run_number }}-,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=raw,value=${{ github.run_number }},event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
- name: Build and Push ${{ env.image_name }} | |
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b | |
id: build-push | |
with: | |
context: ./web | |
file: ./web/Dockerfile | |
# only push to ECR on PR and commits to main branch | |
push: ${{ github.event_name == 'pull_request' || github.ref_name == 'main' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Slack Release Notfication | |
uses: ravsamhq/notify-slack-action@master | |
if: always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
notification_title: "New *WEB* image" | |
message_format: "${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" | |
notify_when: 'success' # default is 'success,failure,warnings' | |
footer: "Linked Repo <{repo_url}|{repo}> | <{workflow_url}|View Workflow>" | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }} # required | |
- name: Send Slack Notfication | |
uses: ravsamhq/notify-slack-action@master | |
if: always() | |
with: | |
status: ${{ job.status }} | |
notify_when: 'failure,warnings' # default is 'success,failure,warnings' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required |