From 4da5e53982316d674a2150c3fe30ee01cbd6b81e Mon Sep 17 00:00:00 2001 From: jsondoe9 <79407641+jsondoe9@users.noreply.github.com> Date: Mon, 7 Feb 2022 20:15:27 +0100 Subject: [PATCH] ci: Add workflows (#1) --- .github/workflows/build_n_push.yml | 45 +++++++++++++++++++ .github/workflows/upstream_sync.yaml | 66 ++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 .github/workflows/build_n_push.yml create mode 100644 .github/workflows/upstream_sync.yaml diff --git a/.github/workflows/build_n_push.yml b/.github/workflows/build_n_push.yml new file mode 100644 index 0000000..9c1e3d2 --- /dev/null +++ b/.github/workflows/build_n_push.yml @@ -0,0 +1,45 @@ +name: "Build and push" + +on: + push: + branches: + - "master" + workflow_dispatch: + +jobs: + build_n_push: + name: Build and push + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: jsondoe9/metube + tags: | + type=sha,prefix=sha-,format=short + type=raw,value=latest,enable=true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/upstream_sync.yaml b/.github/workflows/upstream_sync.yaml new file mode 100644 index 0000000..4a84c00 --- /dev/null +++ b/.github/workflows/upstream_sync.yaml @@ -0,0 +1,66 @@ +name: "Upstream Sync" + +on: + schedule: + - cron: '1 0 * * *' + workflow_dispatch: + +jobs: + + sync: + name: Sync with upstream + runs-on: ubuntu-latest + + outputs: + has_new_commits: ${{ steps.sync.outputs.has_new_commits }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: sync/master + + - name: Sync changes with upstream + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.2 + with: + target_sync_branch: sync/master + target_repo_token: ${{ secrets.GITHUB_TOKEN }} + upstream_sync_branch: master + upstream_sync_repo: alexta69/metube + + - name: New commits found + if: steps.sync.outputs.has_new_commits == 'true' + run: echo "New commits were found to sync." + + - name: No new commits found + if: steps.sync.outputs.has_new_commits == 'false' + run: echo "There were no new commits." + + pr: + name: Create PR for upstream changes + runs-on: ubuntu-latest + needs: sync + if: needs.sync.outputs.has_new_commits == 'true' + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: master + + - name: Reset sync/master branch + run: | + git fetch origin sync/master:sync/master + git reset --hard sync/master + + - name: Create pull request + uses: peter-evans/create-pull-request@v3 + with: + branch: upstream-changes + title: "[sync] Changes from upstream" + body: | + Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) + labels: | + automated + delete-branch: true