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 Push Docker image to Docker Hub | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- "master" | |
jobs: | |
push_to_registry: | |
name: Build, Test and Push Docker image to Docker Hub | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install libfuse | |
shell: bash | |
run: | | |
sudo apt update | |
sudo modprobe fuse | |
sudo chmod 666 /dev/fuse | |
sudo chown root:$USER /etc/fuse.conf | |
sudo apt install fuse libfuse2 libfuse-dev -y | |
- name: Build test image | |
shell: bash | |
run: | | |
cd docker/compose | |
docker-compose build streamarrfs-test | |
- name: Run tests | |
shell: bash | |
run: | | |
cd docker/compose | |
sudo mkdir /tmp/streamarrfs-mnt | |
sudo docker-compose run -v /tmp/streamarrfs-mnt:/tmp streamarrfs-test | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
puttyman/streamarrfs | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/build.Dockerfile | |
target: prod | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |