buildx #302
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: buildx | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 21 * * 5" | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
env: | |
DOCKERHUB_USER: wiserain | |
IMAGE_NAME: wiserain/rclone | |
jobs: | |
buildx: | |
runs-on: ubuntu-22.04 | |
if: github.event_name != 'pull_request' | |
strategy: | |
matrix: | |
rclone-type: [latest, mod] | |
steps: | |
- | |
name: Check if buildx required | |
run: | | |
if [ ${{ matrix.rclone-type }} = "latest" ]; then | |
rclone_install_script_url="https://rclone.org/install.sh" | |
elif [ ${{ matrix.rclone-type }} = "mod" ]; then | |
rclone_install_script_url="https://raw.githubusercontent.com/wiserain/rclone/mod/install.sh" | |
fi | |
curl -fsSL $rclone_install_script_url | sudo bash | |
RCLONE_VER=$(rclone version | head -n1 | cut -f2 -dv) | |
docker pull ${{ env.IMAGE_NAME }}:$RCLONE_VER && X_SKIP=true || X_SKIP=false | |
[[ $GITHUB_EVENT_NAME != "schedule" ]] && X_SKIP=false | |
echo "X_SKIP=$X_SKIP" >> $GITHUB_ENV | |
- | |
name: Checkout | |
if: env.X_SKIP == 'false' | |
uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
if: env.X_SKIP == 'false' | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Buildx | |
if: env.X_SKIP == 'false' | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Initial Buildx | |
if: env.X_SKIP == 'false' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: ${{ env.IMAGE_NAME }}:testing | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
RCLONE_TYPE=${{ matrix.rclone-type }} | |
- | |
name: Load Built Image and Get Variables | |
if: env.X_SKIP == 'false' | |
id: vars | |
run: | | |
docker buildx build \ | |
-t ${{ env.IMAGE_NAME }}:testing \ | |
--platform=linux/amd64 \ | |
--build-arg RCLONE_TYPE=${{ matrix.rclone-type }} \ | |
--load \ | |
. | |
VER=$(docker run --rm --entrypoint=/usr/bin/rclone ${{ env.IMAGE_NAME }}:testing version | head -n1 | cut -f2 -d'v') | |
echo "APP_VER=$VER" >> $GITHUB_ENV | |
- | |
name: Login to docker.io | |
if: env.X_SKIP == 'false' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Login to ghcr.io | |
if: env.X_SKIP == 'false' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Buildx and Push | |
if: env.X_SKIP == 'false' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ matrix.rclone-type }} | |
${{ env.IMAGE_NAME }}:${{ env.APP_VER }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ matrix.rclone-type }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.APP_VER }} | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
RCLONE_TYPE=${{ matrix.rclone-type }} | |
push: true | |
- | |
name: Update Dockerhub description | |
if: env.X_SKIP == 'false' | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ env.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ env.IMAGE_NAME }} | |
short-description: ${{ steps.vars.outputs.github_desc }} | |
- | |
name: Notification | |
uses: sarisia/actions-status-discord@v1 | |
if: env.X_SKIP == 'false' && always() | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
description: | | |
${{ env.IMAGE_NAME }}:${{ matrix.rclone-type }} | |
${{ env.IMAGE_NAME }}:${{ env.APP_VER }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ matrix.rclone-type }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.APP_VER }} | |
buildx-on-pr: | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'pull_request' | |
strategy: | |
matrix: | |
rclone-type: [latest, mod] | |
steps: | |
- | |
name: Check if buildx required | |
run: | | |
if [ ${{ matrix.rclone-type }} = "latest" ]; then | |
rclone_install_script_url="https://rclone.org/install.sh" | |
elif [ ${{ matrix.rclone-type }} = "mod" ]; then | |
rclone_install_script_url="https://raw.githubusercontent.com/wiserain/rclone/mod/install.sh" | |
fi | |
curl -fsSL $rclone_install_script_url | sudo bash | |
RCLONE_VER=$(rclone version | head -n1 | cut -f2 -dv) | |
docker pull ${{ env.IMAGE_NAME }}:$RCLONE_VER && X_SKIP=true || X_SKIP=false | |
[[ $GITHUB_EVENT_NAME != "schedule" ]] && X_SKIP=false | |
echo "X_SKIP=$X_SKIP" >> $GITHUB_ENV | |
- | |
name: Checkout | |
if: env.X_SKIP == 'false' | |
uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
if: env.X_SKIP == 'false' | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Buildx | |
if: env.X_SKIP == 'false' | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Initial Buildx | |
if: env.X_SKIP == 'false' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: ${{ env.IMAGE_NAME }}:testing | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
RCLONE_TYPE=${{ matrix.rclone-type }} | |
- | |
name: Login to docker.io | |
if: env.X_SKIP == 'false' && github.actor == github.event.repository.owner.login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Login to ghcr.io | |
if: env.X_SKIP == 'false' && github.actor == github.event.repository.owner.login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Buildx and Push | |
if: env.X_SKIP == 'false' && github.actor == github.event.repository.owner.login | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: | | |
${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }} | |
${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }}-${{ github.event.pull_request.number }} | |
ghcr.io/${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }} | |
ghcr.io/${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }}-${{ github.event.pull_request.number }} | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
RCLONE_TYPE=${{ matrix.rclone-type }} | |
push: true | |
- | |
name: Notification | |
uses: sarisia/actions-status-discord@v1 | |
if: env.X_SKIP == 'false' && always() && github.actor == github.event.repository.owner.login | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
description: | | |
${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }} | |
${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }}-${{ github.event.pull_request.number }} | |
ghcr.io/${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }} | |
ghcr.io/${{ env.IMAGE_NAME }}:testing-${{ matrix.rclone-type }}-${{ github.event.pull_request.number }} |