Merge pull request #17 from nytimes/go122 #14
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: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
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: Docker meta | |
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: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- 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 }} |