From 6c760030afcce432d0de5a16440c950a80736db5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 22 Apr 2024 01:04:14 +0000 Subject: [PATCH] Add GitHub Action file --- .github/workflows/mirror.yml | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 0000000..d3dc7d0 --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,75 @@ +name: Mirror Git + +on: + workflow_dispatch: + schedule: + - cron: "0 0 */21 * *" + +jobs: + mirror: + runs-on: ubuntu-latest + + permissions: + actions: write + contents: write + pages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Clone Git Repo + run: | + REPO=$(basename "${{ github.repository }}") + BRANCH=$(basename "${{ github.ref }}") + git clone --branch $BRANCH ${{ secrets.URL }}/$REPO.git mirror + + - name: Copy GitHub Action file to cloned repo + run: | + mkdir -p mirror/.github/workflows/ + cp .github/workflows/mirror.yml mirror/.github/workflows/ + + - name: Commit and force push to GitHub + run: | + cd mirror + git remote set-url origin https://github.com/${{ github.repository }}.git + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add . + git commit -m "Add GitHub Action file" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.TOKEN }} + repository: ${{ github.repository }} + branch: ${{ github.ref }} + github_url: https://github.com + directory: ./mirror + force: true + + # - name: Release Info + # id: info + # run: | + # response=$(curl -s "https://gitlab.com/api/v4/projects/suyu-emu%2Fsuyu/releases") + # name=$(echo "$response" | jq -r '.[0].name') + # tag=$(echo "$response" | jq -r '.[0].tag_name') + # description=$(echo "$response" | jq -r '.[0].description') + # links=$(echo "$response" | jq -r '.[0].assets.links[]? | select(has("url") and has("name")) | "- [\(.name)](\(.url))"') + + # echo "::set-output name=name::$name" + # echo "::set-output name=tag::$name" + + # echo "## Changes" > description.txt + # echo "${description}" >> description.txt + # echo "## Downloads" >> description.txt + # echo "${links}" >> description.txt + + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # makeLatest: true + # skipIfReleaseExists: true + # tag: ${{ steps.info.outputs.tag }} + # name: ${{ steps.info.outputs.name }} + # bodyFile: "description.txt"