diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index a9779a9..bc84aab 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: ๐Ÿ“š Docs - url: https://github.com/BetaHuhn/action-github-file-sync#-usage - about: Checkout action-github-file-sync's documentation. + url: https://github.com/BetaHuhn/repo-file-sync-action#-usage + about: Checkout repo-file-sync-action's documentation. - name: ๐Ÿš€ Feature Request - url: https://github.com/BetaHuhn/action-github-file-sync/discussions/new?category=ideas + url: https://github.com/BetaHuhn/repo-file-sync-action/discussions/new?category=ideas about: Share ideas for new features - name: โ“ Ask a Question - url: https://github.com/BetaHuhn/action-github-file-sync/discussions/new?category=q-a + url: https://github.com/BetaHuhn/repo-file-sync-action/discussions/new?category=q-a about: Ask the community for help \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a0d37..79766be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,41 @@ ## [v1.1.0] - 2021-01-10 -[Release notes](https://github.com/betahuhn/action-github-file-sync/releases/tag/v1.1.0) ยท [Compare](https://github.com/betahuhn/action-github-file-sync/compare/v1.0.1...v1.1.0) ยท [Tag](https://github.com/betahuhn/action-github-file-sync/tree/v1.1.0) ยท Archive ([zip](https://github.com/betahuhn/action-github-file-sync/archive/v1.1.0.zip) ยท [tar.gz](https://github.com/betahuhn/action-github-file-sync/archive/v1.1.0.tar.gz)) +[Release notes](https://github.com/betahuhn/repo-file-sync-action/releases/tag/v1.1.0) ยท [Compare](https://github.com/betahuhn/repo-file-sync-action/compare/v1.0.1...v1.1.0) ยท [Tag](https://github.com/betahuhn/repo-file-sync-action/tree/v1.1.0) ยท Archive ([zip](https://github.com/betahuhn/repo-file-sync-action/archive/v1.1.0.zip) ยท [tar.gz](https://github.com/betahuhn/repo-file-sync-action/archive/v1.1.0.tar.gz)) ### New features -- [`35e1508`](https://github.com/betahuhn/action-github-file-sync/commit/35e1508) Cleanup tmp directories +- [`35e1508`](https://github.com/betahuhn/repo-file-sync-action/commit/35e1508) Cleanup tmp directories ### Bug fixes -- [`b7e5310`](https://github.com/betahuhn/action-github-file-sync/commit/b7e5310) Fix parsing of boolean config options [skip-ci] +- [`b7e5310`](https://github.com/betahuhn/repo-file-sync-action/commit/b7e5310) Fix parsing of boolean config options [skip-ci] ## [v1.0.1] - 2021-01-09 -[Release notes](https://github.com/betahuhn/action-github-file-sync/releases/tag/v1.0.1) ยท [Compare](https://github.com/betahuhn/action-github-file-sync/compare/v1.0.0...v1.0.1) ยท [Tag](https://github.com/betahuhn/action-github-file-sync/tree/v1.0.1) ยท Archive ([zip](https://github.com/betahuhn/action-github-file-sync/archive/v1.0.1.zip) ยท [tar.gz](https://github.com/betahuhn/action-github-file-sync/archive/v1.0.1.tar.gz)) +[Release notes](https://github.com/betahuhn/repo-file-sync-action/releases/tag/v1.0.1) ยท [Compare](https://github.com/betahuhn/repo-file-sync-action/compare/v1.0.0...v1.0.1) ยท [Tag](https://github.com/betahuhn/repo-file-sync-action/tree/v1.0.1) ยท Archive ([zip](https://github.com/betahuhn/repo-file-sync-action/archive/v1.0.1.zip) ยท [tar.gz](https://github.com/betahuhn/repo-file-sync-action/archive/v1.0.1.tar.gz)) ### Bug fixes -- [`40b7915`](https://github.com/betahuhn/action-github-file-sync/commit/40b7915) Fix parsing of multiple groups +- [`40b7915`](https://github.com/betahuhn/repo-file-sync-action/commit/40b7915) Fix parsing of multiple groups ## [v1.0.0] - 2021-01-09 -[Release notes](https://github.com/betahuhn/action-github-file-sync/releases/tag/v1.0.0) ยท [Tag](https://github.com/betahuhn/action-github-file-sync/tree/v1.0.0) ยท Archive ([zip](https://github.com/betahuhn/action-github-file-sync/archive/v1.0.0.zip) ยท [tar.gz](https://github.com/betahuhn/action-github-file-sync/archive/v1.0.0.tar.gz)) +[Release notes](https://github.com/betahuhn/repo-file-sync-action/releases/tag/v1.0.0) ยท [Tag](https://github.com/betahuhn/repo-file-sync-action/tree/v1.0.0) ยท Archive ([zip](https://github.com/betahuhn/repo-file-sync-action/archive/v1.0.0.zip) ยท [tar.gz](https://github.com/betahuhn/repo-file-sync-action/archive/v1.0.0.tar.gz)) ### New features -- [`a863fe8`](https://github.com/betahuhn/action-github-file-sync/commit/a863fe8) Add support for directories [skip ci] +- [`a863fe8`](https://github.com/betahuhn/repo-file-sync-action/commit/a863fe8) Add support for directories [skip ci] ### Updates -- [`c4c6e88`](https://github.com/betahuhn/action-github-file-sync/commit/c4c6e88) Remove pattern option [skip ci] -- [`22cc9e5`](https://github.com/betahuhn/action-github-file-sync/commit/22cc9e5) Remove delete option [skip ci] +- [`c4c6e88`](https://github.com/betahuhn/repo-file-sync-action/commit/c4c6e88) Remove pattern option [skip ci] +- [`22cc9e5`](https://github.com/betahuhn/repo-file-sync-action/commit/22cc9e5) Remove delete option [skip ci] ### Bug fixes -- [`bb0c4aa`](https://github.com/betahuhn/action-github-file-sync/commit/bb0c4aa) Use Node v12 [skip ci] -- [`1266e84`](https://github.com/betahuhn/action-github-file-sync/commit/1266e84) Use run_id instead of run_number [skip ci] +- [`bb0c4aa`](https://github.com/betahuhn/repo-file-sync-action/commit/bb0c4aa) Use Node v12 [skip ci] +- [`1266e84`](https://github.com/betahuhn/repo-file-sync-action/commit/1266e84) Use run_id instead of run_number [skip ci] ### Breaking changes -- [`75a118d`](https://github.com/betahuhn/action-github-file-sync/commit/75a118d) First release +- [`75a118d`](https://github.com/betahuhn/repo-file-sync-action/commit/75a118d) First release diff --git a/README.md b/README.md index 171c9e6..c8e71b6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@
-# GitHub File Sync Action +# Repo File Sync Action -[![Build CI](https://github.com/BetaHuhn/action-github-file-sync/workflows/Test%20CI/badge.svg)](https://github.com/BetaHuhn/action-github-file-sync/actions?query=workflow%3A%22Test+CI%22) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/BetaHuhn/action-github-file-sync/blob/master/LICENSE) ![David](https://img.shields.io/david/betahuhn/action-github-file-sync) +[![Build CI](https://github.com/BetaHuhn/repo-file-sync-action/workflows/Test%20CI/badge.svg)](https://github.com/BetaHuhn/repo-file-sync-action/actions?query=workflow%3A%22Test+CI%22) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/BetaHuhn/repo-file-sync-action/blob/master/LICENSE) ![David](https://img.shields.io/david/betahuhn/repo-file-sync-action) Keep files like Action workflows or entire directories in sync between multiple repositories. @@ -10,7 +10,7 @@ Keep files like Action workflows or entire directories in sync between multiple ## ๐Ÿ‘‹ Introduction -With [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) you can sync files, like workflow `.yml` files, configuration files or whole directories between repositories. It works by running a GitHub Action in your main repository everytime you push something to that repo. The action will use a `sync.yml` config file to figure out which files it should sync where. If it finds a file which is out of sync it will open a pull request in the target repository with the changes. +With [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) you can sync files, like workflow `.yml` files, configuration files or whole directories between repositories. It works by running a GitHub Action in your main repository everytime you push something to that repo. The action will use a `sync.yml` config file to figure out which files it should sync where. If it finds a file which is out of sync it will open a pull request in the target repository with the changes. ## ๐Ÿš€ Features @@ -41,7 +41,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@master - name: Run GitHub File Sync - uses: BetaHuhn/action-github-file-sync@master + uses: BetaHuhn/repo-file-sync-action@master with: GH_PAT: ${{ secrets.GH_PAT }} ``` @@ -71,7 +71,7 @@ More info on how to specify what files to sync where [below](#%EF%B8%8F-sync-con ## โš™๏ธ Action Inputs -Here are all the inputs [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) takes: +Here are all the inputs [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) takes: | Key | Value | Required | Default | | ------------- | ------------- | ------------- | ------------- | @@ -89,7 +89,7 @@ Here are all the inputs [action-github-file-sync](https://github.com/BetaHuhn/ac ## ๐Ÿ› ๏ธ Sync Configuration -In order to tell [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) what files to sync where, you have to create a `sync.yml` file in the `.github` directory of your main repository (see [action-inputs](#%EF%B8%8F-action-inputs) on how to change the location). +In order to tell [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) what files to sync where, you have to create a `sync.yml` file in the `.github` directory of your main repository (see [action-inputs](#%EF%B8%8F-action-inputs) on how to change the location). The top-level key should be used to specify the target repository in the format `username`/`repository-name`@`branch`, after that you can list all the files you want to sync to that individual repository: @@ -216,13 +216,13 @@ group: ### Custom labels -By default [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) will add the `sync` label to every PR it creates. You can turn this off by setting `PR_LABELS` to false, or specify your own labels: +By default [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) will add the `sync` label to every PR it creates. You can turn this off by setting `PR_LABELS` to false, or specify your own labels: **.github/workflows/sync.yml** ```yml - name: Run GitHub File Sync - uses: BetaHuhn/action-github-file-sync@master + uses: BetaHuhn/repo-file-sync-action@master with: GH_PAT: ${{ secrets.GH_PAT }} PR_LABELS: | @@ -232,13 +232,13 @@ By default [action-github-file-sync](https://github.com/BetaHuhn/action-github-f ### Assign a user to the PR -You can tell [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) to assign users to the PR with `ASSIGNEES`: +You can tell [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) to assign users to the PR with `ASSIGNEES`: **.github/workflows/sync.yml** ```yml - name: Run GitHub File Sync - uses: BetaHuhn/action-github-file-sync@master + uses: BetaHuhn/repo-file-sync-action@master with: GH_PAT: ${{ secrets.GH_PAT }} ASSIGNEES: BetaHuhn @@ -246,7 +246,7 @@ You can tell [action-github-file-sync](https://github.com/BetaHuhn/action-github ### Advanced sync config -Here's how I keep common files in sync across my repositories. The main repository [`github-files`](https://github.com/BetaHuhn/github-files) contains all the files I want to sync and the [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) Action which runs on every push. +Here's how I keep common files in sync across my repositories. The main repository [`github-files`](https://github.com/BetaHuhn/github-files) contains all the files I want to sync and the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) Action which runs on every push. Using groups I can specify which file(s) should be synced to which repositories: @@ -347,7 +347,7 @@ The actual source code of this library is in the `src` folder. - run `yarn lint` or `npm run lint` to run eslint. - run `yarn start` or `npm run start` to run the Action locally. -- run `yarn build` or `npm run build` to produce a production version of [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) in the `dist` folder. +- run `yarn build` or `npm run build` to produce a production version of [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) in the `dist` folder. ## โ” About diff --git a/action.yml b/action.yml index c037314..b331c86 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'GitHub File Sync' +name: 'Repo File Sync Action' description: 'GitHub Action to Sync Files like Workflows Between Repositories.' author: 'BetaHuhn' diff --git a/dist/index.js b/dist/index.js index 89ac2f0..5f31539 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30166,18 +30166,25 @@ __nccwpck_require__(2437).config() const REPLACE_DEFAULT = true -const getVar = ({ key, default: dft, required = false, array = false }) => { +const getVar = ({ key, default: dft, required = false, type = 'string' }) => { const coreVar = core.getInput(key) const envVar = process.env[key] - if (required === false && (coreVar === false || envVar === 'false')) + if (key === 'PR_LABELS' && (coreVar === false || envVar === 'false')) return undefined - if (coreVar !== undefined && coreVar.length >= 1) - return array ? coreVar.split('\n') : coreVar + if (coreVar !== undefined && coreVar.length >= 1) { + if (type === 'array') return coreVar.split('\n') - if (envVar !== undefined && envVar.length >= 1) - return array ? envVar.split(',') : envVar + return coreVar + } + + if (envVar !== undefined && envVar.length >= 1) { + if (type === 'array') return envVar.split(',') + if (type === 'boolean') return envVar === 'true' + + return envVar + } if (required === true) return core.setFailed(`Variable ${ key } missing.`) @@ -30207,18 +30214,17 @@ const context = { }), COMMIT_EACH_FILE: getVar({ key: 'COMMIT_EACH_FILE', + type: 'boolean', default: true }), PR_LABELS: getVar({ key: 'PR_LABELS', default: [ 'sync' ], - required: false, - array: true + type: 'array' }), ASSIGNEES: getVar({ key: 'ASSIGNEES', - required: false, - array: true + type: 'array' }), TMP_DIR: getVar({ key: 'TMP_DIR', @@ -30226,6 +30232,12 @@ const context = { }), DRY_RUN: getVar({ key: 'DRY_RUN', + type: 'boolean', + default: false + }), + SKIP_CLEANUP: getVar({ + key: 'SKIP_CLEANUP', + type: 'boolean', default: false }), GITHUB_REPOSITORY: getVar({ @@ -30552,7 +30564,9 @@ const { COMMIT_PREFIX, PR_LABELS, ASSIGNEES, - DRY_RUN + DRY_RUN, + TMP_DIR, + SKIP_CLEANUP } = __nccwpck_require__(4570) const run = async () => { @@ -30698,7 +30712,7 @@ const run = async () => { --- - This PR was created automatically by the [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) workflow run [#${ process.env.GITHUB_RUN_ID || 0 }](https://github.com/${ GITHUB_REPOSITORY }/actions/runs/${ process.env.GITHUB_RUN_ID || 0 }) + This PR was created automatically by the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) workflow run [#${ process.env.GITHUB_RUN_ID || 0 }](https://github.com/${ GITHUB_REPOSITORY }/actions/runs/${ process.env.GITHUB_RUN_ID || 0 }) `), head: prBranch, base: currentBranch @@ -30737,13 +30751,19 @@ const run = async () => { } }) - core.info('DONE') + if (SKIP_CLEANUP === true) { + core.info('Skipping cleanup') + return + } + + await io.rmRF(TMP_DIR) + core.info('Cleanup complete') } run() .then(() => {}) .catch((err) => { - console.error('ERROR', err) + core.error('ERROR', err) core.setFailed(err.message) }) diff --git a/package-lock.json b/package-lock.json index c849441..e057778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "action-github-file-sync", + "name": "repo-file-sync-action", "version": "1.1.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index 5999a7a..e614548 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "action-github-file-sync", + "name": "repo-file-sync-action", "version": "1.1.0", "description": "GitHub Action to keep files like Action workflows or entire directories in sync between multiple repositories.", "main": "dist/index.js", @@ -10,7 +10,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/betahuhn/action-github-file-sync.git" + "url": "git+https://github.com/betahuhn/repo-file-sync-action.git" }, "keywords": [ "sync", @@ -23,7 +23,7 @@ "author": "Maximilian Schiller ", "license": "MIT", "bugs": { - "url": "https://github.com/betahuhn/action-github-file-sync/issues" + "url": "https://github.com/betahuhn/repo-file-sync-action/issues" }, "homepage": "https://github.com/marketplace/actions/github-file-sync", "dependencies": { diff --git a/src/index.js b/src/index.js index fcb65ec..cca9c6c 100644 --- a/src/index.js +++ b/src/index.js @@ -162,7 +162,7 @@ const run = async () => { --- - This PR was created automatically by the [action-github-file-sync](https://github.com/BetaHuhn/action-github-file-sync) workflow run [#${ process.env.GITHUB_RUN_ID || 0 }](https://github.com/${ GITHUB_REPOSITORY }/actions/runs/${ process.env.GITHUB_RUN_ID || 0 }) + This PR was created automatically by the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) workflow run [#${ process.env.GITHUB_RUN_ID || 0 }](https://github.com/${ GITHUB_REPOSITORY }/actions/runs/${ process.env.GITHUB_RUN_ID || 0 }) `), head: prBranch, base: currentBranch