Docker Image CI #397
This file contains hidden or 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: Docker Image CI | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
check_version: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
application-name: ['qbittorrentvpn'] | |
outputs: | |
qbversion: ${{ steps.qbv.outputs.QBV }} | |
response: ${{ steps.response.outputs.RESPONSE_CODE }} | |
steps: | |
- name: Get latest qbittorrent version | |
id: qbv | |
run: | | |
echo "QBV=$(curl -sX GET "https://api.github.com/repos/qBittorrent/qBittorrent/tags" | jq '.[] | select(.name | index ("alpha") | not) | select(.name | index ("beta") | not) | select(.name | index ("rc") | not) | .name' | head -n 1 | tr -d '"' | cut -d '-' -f 2)" >> $GITHUB_OUTPUT | |
- name: Check if image exists for latest qbittorrent version | |
id: response | |
run: | | |
echo "Latest qbittorrent version: ${{ steps.qbv.outputs.QBV }}" | |
echo "RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://hub.docker.com/v2/namespaces/${{ secrets.DOCKER_USER }}/repositories/${{ matrix.application-name }}/tags/${{ steps.qbv.outputs.QBV }})" >> $GITHUB_OUTPUT | |
- name: Check response code | |
run: | | |
echo "Response code: ${{ steps.response.outputs.RESPONSE_CODE }}" | |
build_and_push: | |
name: Docker image build and push to Docker Hub | |
needs: check_version | |
if: ( needs.check_version.outputs.response != 200 ) || ( github.event_name == 'workflow_dispatch' ) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
application-name: ['qbittorrentvpn'] | |
steps: | |
- name: Debug - Response Code | |
run: echo "Response code received - ${{ needs.check_version.outputs.response }}" | |
- name: Debug - GitHub Event Name | |
run: echo "GitHub event name - ${{ github.event_name }}" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64,linux/arm | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build version tagged multi-arch qbittorrentvpn image | |
run: docker buildx build --platform linux/amd64,linux/arm64,linux/arm -f Dockerfile -t ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }}:${{ needs.check_version.outputs.qbversion }} . --push | |
- name: Build latest tagged multi-arch qbittorrentvpn image | |
run: docker buildx build --platform linux/amd64,linux/arm64,linux/arm -f Dockerfile -t ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }} . --push | |
- name: Build version tagged Synology Docker image | |
run: docker build --file Dockerfile.synology --tag ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }}:${{ needs.check_version.outputs.qbversion }}-synology . | |
- name: Build latest tagged Synology Docker image | |
run: docker build --file Dockerfile.synology --tag ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }}:latest-synology . | |
- name: Push version tagged Synology Docker image to Docker Hub | |
run: docker push ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }}:${{ needs.check_version.outputs.qbversion }}-synology | |
- name: Push latest tagged Synology Docker image to Docker Hub | |
run: docker push ${{ secrets.DOCKER_USER }}/${{ matrix.application-name }}:latest-synology |