Skip to content

Commit

Permalink
Merge pull request #16 from nytimes/pr-build
Browse files Browse the repository at this point in the history
create separate pull request actions workflow
  • Loading branch information
brianfoshee committed Aug 30, 2023
2 parents 3be47bd + 8a9d771 commit fbd6744
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
31 changes: 14 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: Build and Push Docker Image

on:
push:
branches: [ "main" ]
branches:
- main
tags:
- '*'
pull_request:
branches: [ "main" ]

jobs:
build:
Expand Down Expand Up @@ -48,20 +47,18 @@ jobs:
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# commenting out until we get the webhook secret
#- name: Send GitHub Action trigger data to Slack workflow
# id: slack
# uses: slackapi/[email protected]
# if: ${{ github.event_name != 'pull_request' }}
# with:
# payload: |
# {
# "text": "GitHub Actions Build Result: ${{ job.status }}\n triggered_by: ${{ github.actor }}\n job url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n commit url: ${{ github.event.head_commit.url }}"
# }
# env:
# # webhook for #dv-cdp-alerts
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Send GitHub Action trigger data to Slack workflow
id: slack
uses: slackapi/[email protected]
if: ${{ github.event_name != 'pull_request' }}
with:
payload: |
{
"text": "GitHub Actions Build Result: ${{ job.status }}\n triggered_by: ${{ github.actor }}\n job url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n commit url: ${{ github.event.head_commit.url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
43 changes: 43 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Docker Image Build

on:
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
pull-requests: write
security-events: write
statuses: write

steps:
- uses: actions/checkout@v3

- name: Set Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: nytimes/golang-gcloud-sdk
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build Image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit fbd6744

Please sign in to comment.