Create Docker image on new release #1314
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 releases | |
run: | | |
echo "stable_tag=$(curl -fsL https://web-builds.airdcpp.net/stable/ | grep "_64-bit_portable.tar.gz" | grep -v latest | sort -t "_" -k1.14rV | head -n1 | cut -d "_" -f 2)" >> $GITHUB_ENV | |
echo "stable_dl_url=https://web-builds.airdcpp.net/stable/$(curl -fsL https://web-builds.airdcpp.net/stable/ | grep "_64-bit_portable.tar.gz" | grep -v latest | sort -t "_" -k1.14rV | head -n1 | sed -nr 's/.*>(.+)<.*/\1/p')" >> $GITHUB_ENV | |
echo "dev_tag=$(curl -fsL https://web-builds.airdcpp.net/develop/ | grep "_64-bit_portable.tar.gz" | grep -v latest | sort -t "_" -k1.14rV | head -n1 | cut -d "_" -f 2)" >> $GITHUB_ENV | |
echo "dev_dl_url=https://web-builds.airdcpp.net/develop/$(curl -fsL https://web-builds.airdcpp.net/develop/ | grep "_64-bit_portable.tar.gz" | grep -v latest | sort -t "_" -k1.14rV | head -n1 | sed -nr 's/.*>(.+)<.*/\1/p')" >> $GITHUB_ENV | |
- | |
name: Does the 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.stable_tag}}$')" >> $GITHUB_ENV | |
echo "num_dev_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.dev_tag}}$')" >> $GITHUB_ENV | |
- | |
name: Details | |
run: | | |
echo "Stable Version: ${{env.stable_tag}} Existing tags: ${{env.num_rels_found}} DlUrl: ${{env.stable_dl_url}}" | |
echo "Develop Version: ${{env.dev_tag}} Existing tags: ${{env.num_dev_rels_found}} DlUrl: ${{env.dev_dl_url}}" | |
- | |
if: ${{ env.num_rels_found == 0 || env.num_dev_rels_found == 0 }} | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
if: ${{ env.num_rels_found == 0 || env.num_dev_rels_found == 0 }} | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
if: ${{ env.num_rels_found == 0 || env.num_dev_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 stable | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
build-args: | | |
dl_url=${{env.stable_dl_url}} | |
no-cache: true | |
push: true | |
tags: | | |
gangefors/airdcpp-webclient:latest | |
gangefors/airdcpp-webclient:${{ env.stable_tag }} | |
- | |
if: ${{ env.num_dev_rels_found == 0 }} | |
name: Build and push develop | |
id: docker_build_dev | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
build-args: | | |
dl_url=${{env.dev_dl_url}} | |
no-cache: true | |
push: true | |
tags: | | |
gangefors/airdcpp-webclient:${{ env.dev_tag }} |