Update prod (#96) #13
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 to Prod | |
on: | |
push: | |
branches: | |
- prod | |
env: | |
PROJECT_ID: dev-buildly | |
REGION: us | |
IMAGE_NAME: us-docker.pkg.dev/dev-buildly/gcr.io/prod/buildly-core | |
jobs: | |
build: | |
name: Build and Push image to GCR | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# auto generate tag from label defined in Dockerfile | |
- uses: butlerlogic/[email protected] | |
id: tag_version | |
env: | |
GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" | |
with: | |
strategy: docker | |
tag_prefix: "v" | |
# Create release notes | |
- name: Build changelog | |
id: build_changelog | |
uses: mikepenz/release-changelog-builder-action@main | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
# Create release | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag_version.outputs.tagname }} | |
release_name: Release ${{ steps.tag_version.outputs.tagname }} | |
body: ${{ steps.build_changelog.outputs.changelog }} | |
draft: false | |
prerelease: false | |
- id: "auth" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.GCR_JSON_KEY }}" | |
- name: "Set up Cloud SDK" | |
uses: "google-github-actions/setup-gcloud@v1" | |
- name: "Use gcloud CLI" | |
run: "gcloud info" | |
- name: "Docker auth" | |
run: |- | |
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | |
# Build docker image | |
- name: Build docker image | |
run: docker build -t $IMAGE_NAME:latest . | |
# Push docker image to Artifact registry | |
- name: Push to Google Artifact Registry | |
run: docker push $IMAGE_NAME:latest | |
# Send message on Slack | |
- name: Slack Notification | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_MESSAGE: 'Production Docker Image of buildly core pushed to Google Container Registry Successfully' | |
MSG_MINIMAL: true | |
# Send email alert | |
- name: Email Alert | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
username: ${{ secrets.MAIL_USERNAME }} | |
password: ${{ secrets.MAIL_PASSWORD }} | |
subject: Github Actions Build and Push job alert | |
to: ${{ secrets.RECIPIENT_EMAIL }} | |
from: ${{ secrets.SENDER_EMAIL }} | |
body: Production Docker Image of buildly core pushed to Google Container Registry Successfully |