Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github/
.devcontainer/
.dependabot/
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test

on: [push]

jobs:

test-implementation-job:

runs-on: ubuntu-latest

steps:
# To use this repository's private action, you must check out the repository
- name: Checkout
uses: actions/checkout@v2
- name: Test action step
uses: ./ # Uses an action in the root directory
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo: https://github.com/AndreasAugustin/template.git
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# image for dev build environment
######################################
FROM alpine:3.11 as DEV

# install packages
RUN apk add --update --no-cache bash make git zsh curl tmux

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# template

![Lint](https://github.com/AndreasAugustin/template/workflows/Lint/badge.svg)
![Lint](https://github.com/AndreasAugustin/actions-template-sync/workflows/Lint/badge.svg)

## DEV

Expand Down
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Template sync'
description: 'Synchronises changes of the template repository'
author: 'AndreasAugustin'
branding:
icon: cloud
color: green
inputs:
github_token:
description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
required: true
source_repo:
description: 'Repository source of the. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
required: true
runs:
using: 'docker'
image: 'src/Dockerfile'
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
SOURCE_REPO: ${{ inputs.source_repo }}
17 changes: 17 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3.11

# labels
LABEL \
"name"="GitHub template sync" \
"homepage"="https://github.com/marketplace/actions/github-template-sync" \
"repository"="https://github.com/AndreasAugustin/actions-template-sync" \
"maintainer"="Andreas Augustin <[email protected]>"

# install packages
RUN apk add --no-cache git bash openssh-client && \
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config

ADD *.sh /bin/
RUN chmod +x /bin/entrypoint.sh

ENTRYPOINT ["/bin/entrypoint.sh"]
29 changes: 29 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/env bash
set -e

[ -z "${GITHUB_TOKEN}" ] && {
echo "Missing input 'github_token: \${{ secrets.GITHUB_TOKEN }}'.";
exit 1;
};

if [[ -z "${SOURCE_REPO}" ]]; then
echo "Missing input 'source_repo: \${{ input.source_repo }}'.;"
exit 1
fi

UPSTREAM_REPO="${SOURCE_REPO}"
SOURCE_BRANCH="master"
NEW_BRANCH="chore/template_sync"

echo "start sync"
git config --unset-all http."https://github.com/".extraheader
git remote set-url origin "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY"
git remote add tmp_upstream "$UPSTREAM_REPO"
echo "fetching source repo ${UPSTREAM_REPO}"
git fetch tmp_upstream
git remote --verbose
echo "push to new branch ${NEW_BRANCH}"
git push origin "refs/remotes/tmp_upstream/${SOURCE_BRANCH}:refs/heads/${NEW_BRANCH}"
echo "cleanup"
git remote rm tmp_upstream
git remote --verbose