-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d4f6791
Showing
10 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: "⚠️ Report an Issue" | ||
description: "Something Not Working Right? Please let us know..." | ||
labels: ["bug"] | ||
assignees: | ||
- smashedr | ||
|
||
body: | ||
- type: input | ||
id: website | ||
validations: | ||
required: false | ||
attributes: | ||
label: Repo Link | ||
description: Please provide a link to the repository or workflow you are having issues with if possible. | ||
|
||
- type: textarea | ||
id: description | ||
validations: | ||
required: true | ||
attributes: | ||
label: Details | ||
description: Please describe the issue you are experiencing and how to reproduce. | ||
placeholder: Provide as many details as you can... | ||
|
||
- type: textarea | ||
id: logs | ||
validations: | ||
required: false | ||
attributes: | ||
label: Log Output | ||
description: Paste any relevant logs or output in this box. | ||
render: shell | ||
|
||
- type: markdown | ||
attributes: | ||
value: | | ||
All issues/bugs that we can verify will be fixed. Thank you for taking the time to make this report! |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: "💡 Request a Feature" | ||
about: Request a New Feature or Enhancement in the Discussions. | ||
url: https://github.com/cssnr/mirror-repository-action/discussions/new?category=feature-requests | ||
|
||
- name: "❔ Ask a Question" | ||
about: Ask a General Question or start a Discussions. | ||
url: https://github.com/cssnr/mirror-repository-action/discussions/new?category=q-a | ||
|
||
- name: "💬 Join Discord" | ||
about: Chat with us about Issues, Features, Questions and More. | ||
url: https://discord.gg/wXy6m2X8wY | ||
|
||
- name: "📝 Submit Feedback" | ||
about: Send General Feedback. | ||
url: https://cssnr.github.io/feedback/?app=Mirror%20Repository%20Action |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "Tags" | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
tags: | ||
name: "Tags" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: "Update Tags" | ||
uses: cssnr/update-version-tags-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Test" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "**" | ||
tags: | ||
- "**" | ||
|
||
jobs: | ||
test: | ||
name: "Test" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Test Local Action" | ||
id: test | ||
uses: ./ | ||
with: | ||
#url: https://codeberg.org/cssnr/mirror-repository-action | ||
host: https://codeberg.org | ||
#owner: cssnr | ||
#repo: mirror-repository-action | ||
username: shaner | ||
password: ${{ secrets.CODEBERG_TOKEN }} | ||
|
||
lint: | ||
name: "Lint" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Run ShellCheck" | ||
uses: ludeeus/[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea/ | ||
*.iml | ||
.vscode/ | ||
venv/ | ||
__pycache__/ | ||
*.pyc | ||
.env | ||
.secrets | ||
.vars |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"semi": false, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": ["**/*.html", "**/*.yaml", "**/*.yml"], | ||
"options": { | ||
"singleQuote": false | ||
} | ||
}, | ||
{ | ||
"files": ["**/*.json", "**/*.yaml", "**/*.yml"], | ||
"options": { | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --update --no-cache bash git | ||
|
||
COPY src/ /src | ||
|
||
ENTRYPOINT ["bash", "/src/main.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
[![Tags](https://img.shields.io/github/actions/workflow/status/cssnr/mirror-repository-action/tags.yaml?logo=github&logoColor=white&label=tags)](https://github.com/cssnr/mirror-repository-action/actions/workflows/tags.yaml) | ||
[![Test](https://img.shields.io/github/actions/workflow/status/cssnr/mirror-repository-action/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/mirror-repository-action/actions/workflows/test.yaml) | ||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_mirror-repository-action&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cssnr_mirror-repository-action) | ||
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/mirror-repository-action?logo=github)](https://github.com/cssnr/mirror-repository-action/releases/latest) | ||
[![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/mirror-repository-action?logo=github&logoColor=white&label=updated)](https://github.com/cssnr/mirror-repository-action/graphs/commit-activity) | ||
[![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/mirror-repository-action?logo=htmx&logoColor=white)](https://github.com/cssnr/mirror-repository-action) | ||
[![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white)](https://cssnr.github.io/) | ||
[![Discord](https://img.shields.io/discord/899171661457293343?logo=discord&logoColor=white&label=discord&color=7289da)](https://discord.gg/wXy6m2X8wY) | ||
|
||
# Mirror Repository Action | ||
|
||
Mirror Git Repository to Remote Host. | ||
|
||
- [Inputs](#Inputs) | ||
- [Support](#Support) | ||
- [Contributing](#Contributing) | ||
- [Development](#Development) | ||
|
||
## Inputs | ||
|
||
| input | required | default | description | | ||
| -------- | ------------ | ---------- | ---------------------------------------------------- | | ||
| url | No if `host` | - | Full URL to Mirror, overrides: `host`/`owner`/`repo` | | ||
| host | No if `url` | - | Full Host to Mirror, example: `https://codeberg.org` | | ||
| owner | No | Repo Owner | Repository Owner of Mirror | | ||
| repo | No | Repo Name | Repository Name of Mirror | | ||
| username | No | Repo Owner | Username for Authentication to Mirror | | ||
| password | Yes | - | Token or Password for Authentication to Mirror | | ||
|
||
Note: You must provide either a `url` or `host`. | ||
|
||
If providing a `host` the `url` is created from `host`/`owner`/`repo` using either provided values or source repository values. | ||
|
||
```yaml | ||
name: 'Mirror' | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- '**' | ||
tags: | ||
- '**' | ||
|
||
jobs: | ||
mirror: | ||
name: 'Mirror' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 'Mirror to Codeberg' | ||
id: test | ||
uses: cssnr/mirror-repository-action@master | ||
with: | ||
url: https://codeberg.org/shaner/codeberg-mirror | ||
#host: https://codeberg.org | ||
#owner: shaner | ||
#repo: codeberg-mirror | ||
username: shaner | ||
password: ${{ secrets.CODEBERG_TOKEN }} | ||
``` | ||
# Support | ||
For general help or to request a feature, see: | ||
- Q&A Discussion: https://github.com/cssnr/mirror-repository-action/discussions/categories/q-a | ||
- Request a Feature: https://github.com/cssnr/mirror-repository-action/discussions/categories/feature-requests | ||
If you are experiencing an issue/bug or getting unexpected results, you can: | ||
- Report an Issue: https://github.com/cssnr/mirror-repository-action/issues | ||
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY | ||
- Provide General | ||
Feedback: [https://cssnr.github.io/feedback/](https://cssnr.github.io/feedback/?app=Mirror%20Artifacts%20Action) | ||
# Contributing | ||
Currently, the best way to contribute to this project is to star this project on GitHub. | ||
Additionally, you can support other GitHub Actions I have published: | ||
- [VirusTotal Action](https://github.com/cssnr/virustotal-action) | ||
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action) | ||
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action) | ||
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action) | ||
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action) | ||
- [Portainer Stack Deploy](https://github.com/cssnr/portainer-stack-deploy-action) | ||
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action) | ||
For a full list of current projects to support visit: [https://cssnr.github.io/](https://cssnr.github.io/) | ||
# Development | ||
1. Install `act`: https://nektosact.com/installation/index.html | ||
2. Run `act -j test` | ||
|
||
For advanced using with things like secrets, variables and context see: https://nektosact.com/usage/index.html | ||
|
||
You should also review the options from `act --help` | ||
|
||
Note, the `.env`, `.secrets` and `.vars` files are automatically sourced with no extra options. | ||
To source `event.json` you need to run act with `act -e event.json` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "Mirror Repository Action" | ||
description: "Mirror Git Repository to Remote Host." | ||
author: "Shane" | ||
branding: | ||
icon: "git-merge" | ||
color: "black" | ||
|
||
inputs: | ||
url: | ||
description: "Remote Repository URL" | ||
required: false | ||
host: | ||
description: "Remote Repository Host" | ||
required: false | ||
owner: | ||
description: "Remote Repository Owner" | ||
required: false | ||
repo: | ||
description: "Remote Repository Name" | ||
required: false | ||
username: | ||
description: "Remote Repository Username" | ||
required: false | ||
password: | ||
description: "Remote Repository Password" | ||
required: false | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "Running: ${0} as: $(whoami) in: $(pwd)" | ||
|
||
echo "---------- GITHUB ----------" | ||
|
||
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" | ||
echo "GITHUB_REF: ${GITHUB_REF}" | ||
#echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}" | ||
#echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}" | ||
#echo "GITHUB_REF_NAME: ${GITHUB_REF_NAME}" | ||
#echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}" | ||
#echo "GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER}" | ||
#echo "GITHUB_RUN_ATTEMPT: ${GITHUB_RUN_ATTEMPT}" | ||
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}" | ||
echo "GITHUB_REPOSITORY_OWNER: ${GITHUB_REPOSITORY_OWNER}" | ||
|
||
echo "---------- INPUTS ----------" | ||
|
||
[[ -n "${INPUT_URL}" ]] && REMOTE_URL="${INPUT_URL}" | ||
#echo "REMOTE_URL: ${REMOTE_URL}" | ||
if [ -z "${INPUT_URL}" ];then | ||
HOST="${INPUT_HOST:?err}" | ||
echo "HOST: ${HOST}" | ||
OWNER="${INPUT_USER:-${GITHUB_REPOSITORY_OWNER}}" | ||
echo "OWNER: ${OWNER}" | ||
REPO="${INPUT_REPO:-$(echo "${GITHUB_REPOSITORY}" | awk -F'/' '{print $2}')}" | ||
echo "REPO: ${REPO}" | ||
REMOTE_URL="${HOST}/${OWNER}/${REPO}" | ||
fi | ||
|
||
echo -e "REMOTE_URL: \u001b[33;1m${REMOTE_URL}" | ||
|
||
USERNAME="${INPUT_USERNAME:-${OWNER}}" | ||
echo "USERNAME: ${USERNAME}" | ||
|
||
PASSWORD="${INPUT_PASSWORD:?err}" | ||
#echo "PASSWORD: ${PASSWORD}" | ||
|
||
GIT_HOST=$(echo "${REMOTE_URL}" | awk -F'/' '{print $3}') | ||
echo "GIT_HOST: ${GIT_HOST}" | ||
|
||
git config --global --add safe.directory "$(pwd)" | ||
|
||
git config --global credential.helper cache | ||
git credential approve <<EOF | ||
protocol=https | ||
host=${GIT_HOST} | ||
username=${USERNAME} | ||
password=${PASSWORD} | ||
EOF | ||
|
||
#echo "git branch: $(git branch)" | ||
#BRANCH1="$(git rev-parse --abbrev-ref HEAD)" | ||
#echo "BRANCH1: ${BRANCH1}" | ||
BRANCH="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)" | ||
echo "BRANCH: ${BRANCH}" | ||
|
||
git remote add mirror "${REMOTE_URL}" | ||
git remote -v | ||
|
||
git push --tags --follow-tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*" | ||
|
||
#if [ "${GITHUB_EVENT_NAME}" == "push" ];then | ||
# echo "event: ${GITHUB_EVENT_NAME}" | ||
# #git push mirror "${BRANCH}" | ||
# git push --tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*" | ||
#else | ||
# echo -e "\u001b[31;1mUNKNOWN event: ${GITHUB_EVENT_NAME}" | ||
#fi | ||
|
||
echo -e "\u001b[32;1mFinished Success." |