trig #17
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 docker images | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
app: | |
- deepmod2 | |
- deepmod2-gpu | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Read version file | |
id: get_version | |
run: echo "version=$(cat ${{ matrix.app }}/version)" >> $GITHUB_OUTPUT | |
- name: Check if files changed | |
id: files_changed | |
run: | | |
if git diff-tree --no-commit-id --name-only -r HEAD | grep -q "^${{ matrix.app }}/"; then | |
echo "changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "changed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Build and push Docker image | |
if: ${{ steps.files_changed.outputs.changed == 'true' }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: ${{ matrix.app }} | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.app }}:${{ steps.get_version.outputs.version }} | |
build-args: | | |
BUILD_VERSION=${{ steps.get_version.outputs.version }} | |
- name: Debug Output | |
run: | | |
echo "Event name: ${{ github.event_name }}" | |
echo "App: ${{ matrix.app }}" | |
echo "Files changed: ${{ steps.files_changed.outputs.changed }}" | |
echo "Version: ${{ steps.get_version.outputs.version }}" |