trigger workflow #28
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, Test, and Publish | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
needs: docker-publish | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, macos-13] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Set up Homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Create and activate virtual environment | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
- name: Install dependencies | |
run: | | |
source venv/bin/activate | |
pip3 install . -v | |
- name: Test the package | |
run: | | |
source venv/bin/activate | |
#pytest to come | |
docker-publish: | |
runs-on: ubuntu-latest # Docker actions are run on Linux | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Check version changes | |
run: | | |
echo $(git diff HEAD~1 HEAD -- ./version) >> ./version | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v20 | |
id: verify-changed-files | |
with: | |
files: | | |
./version | |
- name: Set up Docker Buildx | |
if: contains(steps.verify-changed-files.outputs.changed_files, './version') | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Container Registry | |
if: contains(steps.verify-changed-files.outputs.changed_files, './version') | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.Docker }} | |
- name: Build and push Docker image | |
if: contains(steps.verify-changed-files.outputs.changed_files, './version') | |
uses: ./version | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository }}:latest | |
- name: Verify the Docker image | |
if: contains(steps.verify-changed-files.outputs.changed_files, './version') | |
run: | | |
docker pull ghcr.io/${{ github.repository }}:latest | |
docker run ghcr.io/${{ github.repository }}:latest |