smaple yaml code for prevent_merge

This commit is contained in:
swastik7777 2024-06-05 12:29:00 +05:30 committed by GitHub
parent 0606d6852a
commit 4bc9099276
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
name: Build Container Image
on:
push:
branches:
- main
- master
# Check if the commit message contains 'BUILD_CONTAINER_IMAGE'
paths-ignore:
- '.github/workflows/**'
pull_request:
branches:
- main
- master
jobs:
build:
if: |
github.event_name == 'push' &&
(github.event.head_commit.message contains 'BUILD_CONTAINER_IMAGE' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') ||
github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: <your-dockerhub-username>/guestbook-go:latest