Skip to content

docker CI only run on related file change&don't push on forks #27

docker CI only run on related file change&don't push on forks

docker CI only run on related file change&don't push on forks #27

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
paths:
- .github/workflows/docker-image.yml
- backend/**.py
- backend/Dockerfile
pull_request:
branches: [ "main" ]
paths:
- .github/workflows/docker-image.yml
- backend/**.py
- backend/Dockerfile
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- run: echo "${{ github.repository_owner }}"
- run: echo "${{ github.ref }}"
- name: Log in to Docker Hub
if: github.repository_owner == 'FedCampus' && contains(github.ref, 'main')
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: fedcampus/fedkit-backend
flavor: |
latest=true
tags: |
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./backend
file: ./backend/Dockerfile
push: ${{ github.repository_owner == 'FedCampus' && contains(github.ref, 'main') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}