Skip to content

Update versions (#241) #336

Update versions (#241)

Update versions (#241) #336

Workflow file for this run

name: Build and Push docker image
on:
pull_request:
branches: master
push:
branches:
- '*'
tags:
- v*
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'wahyd4/aria2-ariang-docker'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
-
name: Update APP VERSION
if: contains(github.ref, '/tags/v')
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo $VERSION > APP_VERSION
-
name: Prepare
id: prepare
run: |
DOCKER_IMAGE=wahyd4/aria2-ui
DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file Dockerfile .
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
-
name: Login to DockerHub
if: contains(github.ref, '/heads/master') || contains(github.ref, '/tags/v')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}
-
name: Push docker images to Dockerhub
if: contains(github.ref, '/heads/master') || contains(github.ref, '/tags/v')
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
-
name: Inspect image
if: contains(github.ref, '/heads/master') || contains(github.ref, '/tags/v')
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
-
name: Commit changes
if: contains(github.ref, '/tags/v')
uses: EndBug/add-and-commit@v7
with:
author_name: junv-repo-bot
author_email: me@toozhao.com
message: 'Update version'
add: 'APP_VERSION'
push: true
branch: master
-
name: Update tag
if: contains(github.ref, '/tags/v')
env:
API_KEY: ${{ secrets.BadgeAPIKey }}
run: |
VERSION=${GITHUB_REF#refs/tags/v}
curl --max-time 6 -XPUT -D- 'https://badges.toozhao.com/val/aria2-ui-docker' \
-H 'Content-Type: application/json' \
-H 'API_KEY': ${API_KEY} \
-d '{"value": "'${VERSION}'"}' || true