2017 © Pedro PelĂĄez
 

robo-tasks robo-git-artefact

Robo task to push git artefact to remote repository

image

integratedexperts/robo-git-artefact

Robo task to push git artefact to remote repository

  • Tuesday, April 24, 2018
  • by alexdesignworks
  • Repository
  • 1 Watchers
  • 6 Stars
  • 10,841 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 5 Open issues
  • 14 Versions
  • 46 % Grown

The README.md

Git Artifact logo , (*1)

Package and push files to a remote repository

[![GitHub Issues](https://img.shields.io/github/issues/drevops/git-artifact.svg)](https://github.com/drevops/git-artifact/issues) [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/git-artifact.svg)](https://github.com/drevops/git-artifact/pulls) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/git-artifact) [![codecov](https://codecov.io/gh/drevops/git-artifact/branch/main/graph/badge.svg?token=QNBXCIBK5J)](https://codecov.io/gh/drevops/git-artifact) [![Total Downloads](https://poser.pugx.org/drevops/behat-screenshot/downloads)](https://packagist.org/packages/drevops/git-artifact) ![LICENSE](https://img.shields.io/github/license/drevops/git-artifact) ![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot) [![Test PHP](https://github.com/drevops/git-artifact/actions/workflows/test-php.yml/badge.svg)](https://github.com/drevops/git-artifact/actions/workflows/test-php.yml) [![CircleCI](https://circleci.com/gh/drevops/git-artifact.svg?style=shield)](https://circleci.com/gh/drevops/git-artifact)

What is it?

A tool to assemble a code artifact from your codebase, remove unnecessary files, and push it into a separate Git repository., (*2)

Why?

In hosting environments like Acquia, there are restrictions on the languages or frameworks available for building applications—for instance, the inability to run composer install due to a read-only filesystem. Consequently, a website source code has to be developed in a separate (source) repository, then assembled into a code artifact either locally or via CI, and then transferred to the hosting provider's version control system (destination repository)., (*3)

This tool facilitates such processes seamlessly: it uses a .gitignore.deployment file to determine which files should be transferred to the destination repository, ensuring only necessary files are included and leaving out those specified by the ignore file., (*4)

Furthermore, since the destination repository requires a commit to incorporate changes from the artifact (like CSS, JS, etc.), the tool offers two options for this commit: force-push or branch, accommodating different workflow preferences., (*5)

See example of deployed artifact in Artifact branches., (*6)

Modes

force-push mode (default)

Push the packaged artifact to the same branch in the destination repository, carrying over the history from the source repository while overwriting the existing history in the destination repository., (*7)

diagram of force-push mode, (*8)

Use case

Forwarding all changes from the source repository to the destination repository as-is for every branch: for example, a commit in the source repository branch feature/123 would create a commit in the destination repository branch feature/123. The next commit to the source repository branch feature/123 would update the destination repository branch feature/123 with the changes, but would overwrite the last "deployment" commit., (*9)

branch mode

Push packaged artifact to the new branch on each deployment, preserving history from the source repository, but requiring to trigger a deployment of newly created branch after each deployment., (*10)

diagram of branch mode, (*11)

Use case

Creating a new branch in the destination repository for every tag created in the source repository: for example, a tag 1.2.3 in the source repository would create a branch deployment/1.2.3 in the destination repository. The addition of the new tags would create new unique branches in the destination repository., (*12)

Installation

composer require --dev drevops/git-artifact

or download the latest release from the GitHub releases page., (*13)

Usage

./git-artifact git@github.com:yourorg/your-repo-destination.git

This will create an artifact from current directory and will send it to the specified remote repository into the same branch as a current one., (*14)

Run in CI

See examples:, (*15)

Call from CI configuration or deployment script:, (*16)

export DEPLOY_BRANCH=<YOUR_CI_PROVIDER_BRANCH_VARIABLE>
./git-artifact git@github.com:yourorg/your-repo-destination.git \
  --branch="${DEPLOY_BRANCH}" \
  --push

See extended and fully-configured example in the Scaffold project., (*17)

Options

Name Default value Description
--branch [branch] Destination branch with optional tokens.
--gitignore Path to gitignore file to replace current .gitignore.
--message Deployment commit Commit message with optional tokens.
--mode force-push Mode of artifact build: branch, force-push or diff.
--no-cleanup Do not cleanup after run.
--now Internal value used to set internal time.
--dry-run Run without pushing to the remote repository.
--log Path to the log file.
--root Path to the root for file path resolution. Uses current directory if not specified.
--show-changes Show changes made to the repo by the build in the output.
--src Directory where source repository is located. Uses root directory if not specified.
-h, --help Display help for the given command. Displays help for the artifact command if no command given.
-q, --quiet Do not output any message.
-V, --version Display this application version.
--ansi Force ANSI output. Use --no-ansi to disable.
-n, --no-interaction Do not ask any interactive question.
-v, --verbose Increase the verbosity of messages: 1 for normal, 2 for more verbose, 3 for debug.

Modifying artifact content

--gitignore option allows to specify the path to the artifact's .gitignore file that replaces existing .gitignore (if any) during the build. Any files no longer ignored by the replaced artifact's .gitignore are added into the deployment commit. If there are no no-longer-excluded files, the deployment commit is still created, to make sure that the deployment timestamp is captured., (*18)

Token support

Tokens are pre-defined strings surrounded by [ and ] and may contain optional formatter (for flexibility). For example, [timestamp:Y-m-d] is replaced with the current timestamp in format Y-m-d (token formatter), which is PHP date() expected format., (*19)

Both --branch and --message option values support token replacement., (*20)

Available tokens:, (*21)

  • [timestamp:FORMAT] - current time with a PHP date()-compatible FORMAT.
  • [branch] - current branch in the source repository.
  • [safebranch] - current branch in the source repository with with all non-alphanumeric characters replaced with - and lowercased.
  • [tags:DELIMITER] - tags from the latest commit in the source repository separated by a DELIMITER.

Maintenance

Lint and fix code

composer lint
composer lint-fix

Run tests

composer test

Repository created using https://getscaffold.dev/ project scaffold template, (*22)

The Versions

24/04 2018

dev-master

9999999-dev

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

24/04 2018

0.2.4

0.2.4.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

24/04 2018

dev-fix-no-cleanup

dev-fix-no-cleanup

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

05/02 2018

0.2.3

0.2.3.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

05/02 2018

dev-feature/18-remove-excluded-committed-files

dev-feature/18-remove-excluded-committed-files

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

10/11 2017

0.2.2

0.2.2.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

10/11 2017

0.2.1

0.2.1.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

10/11 2017

0.2.0

0.2.0.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

28/10 2017

0.1.4

0.1.4.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

28/10 2017

dev-feature/4-report-to-file

dev-feature/4-report-to-file

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

20/09 2017

0.1.3

0.1.3.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

20/09 2017

0.1.2

0.1.2.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

06/09 2017

0.1.1

0.1.1.0

Robo task to push git artefact to remote repository

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk

06/09 2017

0.1.0

0.1.0.0

Robo task to push git artefact to remote repository

  Sources   Download

The Requires

 

The Development Requires