Create Docker image on new release #975
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: Create Docker image on new release | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 20 * * *' | |
jobs: | |
buildDockerImage: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Get latest airdcpp release | |
run: | | |
echo "release_tag=$(curl -fsL 'https://api.github.com/repos/airdcpp-web/airdcpp-webclient/releases/latest' | jq -r '.tag_name')" >> $GITHUB_ENV | |
- | |
name: Does latest release exist as docker image | |
run: | | |
echo "num_rels_found=$(curl -fsL 'https://hub.docker.com/v2/repositories/gangefors/airdcpp-webclient/tags/?page_size=10&ordering=last_updated' | jq -r '.results[].name' | grep -c '${{env.release_tag}}')" >> $GITHUB_ENV | |
- | |
run: | | |
echo "Version: ${{env.release_tag}} Existing tags: ${{env.num_rels_found}}" | |
- | |
if: ${{ env.num_rels_found == 0 }} | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
if: ${{ env.num_rels_found == 0 }} | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
if: ${{ env.num_rels_found == 0 }} | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: gangefors | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
if: ${{ env.num_rels_found == 0 }} | |
name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
no-cache: true | |
push: true | |
tags: | | |
gangefors/airdcpp-webclient:latest | |
gangefors/airdcpp-webclient:${{ env.release_tag }} |