Skip to content

Sync+build+push Protonmail-bridge #297

Sync+build+push Protonmail-bridge

Sync+build+push Protonmail-bridge #297

name: Sync+build+push Protonmail-bridge
on:
# Triggers the workflow on push or pull request events but only for the main branch
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
get_commits:
#if: false
runs-on: ubuntu-latest
# https://lannonbr.com/blog/2020-04-16-gh-actions-job-outputs
outputs:
# https://github.com/shenxn/protonmail-bridge-docker
LOCAL_FORK: ${{ steps.commits.outputs.SETLOCAL_FORK }}
REMOTE_FORK: ${{ steps.commits.outputs.SETREMOTE_FORK }}
# https://github.com/ProtonMail/proton-bridge
LOCAL_PARENT: ${{ steps.commits.outputs.SETLOCAL_PARENT }}
REMOTE_PARENT: ${{ steps.commits.outputs.SETREMOTE_PARENT }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'Protonmail-bridge' # branch
- name: set local and remote latest commit as environment variables
id: commits
# https://lannonbr.com/blog/2020-04-16-gh-actions-job-outputs
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
run: |
echo "SETREMOTE_FORK=$(git ls-remote https://github.com/shenxn/protonmail-bridge-docker HEAD | awk '{ print $1 }')" >> $GITHUB_OUTPUT
echo "SETLOCAL_FORK=$(cat last_sync_with_original_repo_commit_id)" >> $GITHUB_OUTPUT
echo "SETREMOTE_PARENT=$(git ls-remote https://github.com/ProtonMail/proton-bridge HEAD | awk '{ print $1 }')" >> $GITHUB_OUTPUT
echo "SETLOCAL_PARENT=$(cat last_sync_with_original_parent_repo_commit_id)" >> $GITHUB_OUTPUT
repo_sync:
needs: [get_commits]
runs-on: ubuntu-latest
# https://lannonbr.com/blog/2020-04-16-gh-actions-job-outputs
#if: false
if: needs.get_commits.outputs.LOCAL_FORK != needs.get_commits.outputs.REMOTE_FORK || needs.get_commits.outputs.LOCAL_PARENT != needs.get_commits.outputs.REMOTE_PARENT
steps:
- name: repo-sync
uses: wei/git-sync@v3
with:
source_repo: "https://github.com/shenxn/protonmail-bridge-docker"
source_branch: "master"
destination_repo: "[email protected]:schklom/Mirror-workflows.git"
destination_branch: "Protonmail-bridge"
ssh_private_key: ${{ secrets.GITSYNCACTION }}
# uses: repo-sync/github-sync@v2
# with:
# source_repo: "https://github.com/hkalexling/Mango.git"
# source_branch: "master"
# destination_branch: "Protonmail-bridge"
# github_token: ${{ secrets.REPO_SYNC_GITHUB_SYNC_PERSONAL_ACCESS_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'Protonmail-bridge' # branch
- name: get most recent commit id on original repo, for next comparison on sync PART 1
run: |
git ls-remote https://github.com/shenxn/protonmail-bridge-docker HEAD | awk '{ print $1 }' > last_sync_with_original_repo_commit_id
git ls-remote https://github.com/ProtonMail/proton-bridge HEAD | awk '{ print $1 }' > last_sync_with_original_parent_repo_commit_id
- name: Commit and push the change
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Add last_sync_with_original_repo_commit_id + last_sync_with_original_parent_repo_commit_id
- name: Change golang image
run: |
filename="build/Dockerfile"
sed -i "s|carlosedp/golang:1.18|golang:latest|" $filename
- name: Commit and push the change
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Patch to compile
build_push:
needs: [repo_sync]
#needs: [get_commits]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
#repository: 'schklom/Protonmail-bridge'
ref: 'Protonmail-bridge' # branch
# https://github.com/docker/setup-qemu-action#usage
- name: Set up QEMU
uses: docker/[email protected]
#with:
#image: tonistiigi/binfmt:latest
#platforms: all
#platforms: arm/v7
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
#with:
#install: true
#- name: Available platforms
# run: echo ${{ steps.buildx.outputs.platforms }}
# https://github.com/docker/login-action#docker-hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# https://github.com/docker/build-push-action#multi-platform-image
- name: Build and push Protonmail-bridge
uses: docker/build-push-action@v6
with:
context: ./build
file: ./build/Dockerfile
#platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
platforms: linux/amd64,linux/arm64
pull: true
push: true
tags: |
schklom/protonmail-bridge:latest