Skip to content

triger ci/cd

triger ci/cd #3

Workflow file for this run

name: build docker images
on:
push:
paths:
- 'deepmod2/**'
- 'deepmod2-gpu/**'
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@v2
- 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: |
VERSION=$(cat ${{ matrix.app }}/version)
echo "::set-output name=version::$VERSION"
- name: Check if files changed
id: files_changed
run: |
if git diff-tree --no-commit-id --name-only -r HEAD | grep "^${{ matrix.app }}/"; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- name: Build and push Docker image
if: ${{ steps.files_changed.outputs.changed == 'true' }}
run: |
cd ${{ matrix.app }}
docker build --build-arg="BUILD_VERSION=${{ steps.get_version.outputs.version }}" -t ghcr.io/${{ github.repository_owner }}/${{ matrix.app }}:${{ steps.get_version.outputs.version }} .
docker push ghcr.io/${{ github.repository_owner }}/${{ matrix.app }}:${{ steps.get_version.outputs.version }}