Trouble pulling multiple repos using GH actions, deploy key only works for composer file pulling from one repo how to automate several repos? - composer-php

So I am trying to build a deploy action. I want to listen for a merge to a branch on any of several repos and when the merge happens I want to:
Checkout a specific branch
set the php version
run composer update (get the most recent hashes from all repos)
run composer install (clone all the repos locally)
deploy to Acquia
I have everything working until the action tries to check out the repos, I am getting a error:
Failed to execute git clone --mirror -- 'git#github.com:organization/repo1.git' '/home/runner/.cache/composer/vcs/git-github.com-xxxxx.git/'
Cloning into bare repository '/home/runner/.cache/composer/vcs/git-github.com-xxxxx.git'...
Warning: Permanently added the ECDSA host key for IP address 'XXX.XX.XXX.X' to the list of known hosts.
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
In the yaml I have:
name: composer update action
uses: kawax/composer-update-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_NAME: myorganization
GIT_EMAIL: myname#myorganization.edu
COMPOSER_PACKAGES: north*
I have tried using php-composer-v6 but I get the same error. There are more than one repo so the deploy key does not seem to be the right solution.
here is an example of the repositories entries in the composer.json:
"repositories": {
"0": {
"type": "vcs",
"url": "git#github.com:organization/repo1.git",
"no-api": true
},
"1": {
"type": "vcs",
"url": "git#github.com:organization/repo2.git",
"no-api": true
},
There are many repos - nine.

Related

Laravel Nova installation via composer fails on production server

I have added Laravel Nova to our application and purchased a license. On the local server everything works perfectly. However, when I try to deploy the updated application to our linux server and run composer update it says:
Failed to download laravel/nova from dist: /var/www/{myPath} does not exist and could not be created.
Now trying to download from source
Syncing laravel/nova (3.29.0) into cache
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Head to https://github.com/settings/tokens/new It will be stored in "/var/www/{myPath}"
So I created a GitHub Token and added the Laravel Nova credentials to the auth.json file on the server too. Everything should be correct and it is working on the local copy as I said before. However, I am getting the following errors:
[RuntimeException]
Failed to execute git clone --mirror -- 'git#github.com:laravel/nova.git' '/var/www/{myPath}/.cache/composer/vcs/git-github.com-laravel-nova.git/'
Cloning into bare repository '/var/www/{myPath}/.cache/composer/vcs/git-github.com-laravel-nova.git'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How could I solve this problem?
Deleting the /vendor directory and the composer.lock file and running composer install --optimize-autoloader --no-devsolved the problem.
I had a similar problem and finally figured out the cause and its due to the laravel/nova:3.29. A minor upgrade to 3.30 fixed the issue for me without having to delete the whole composer.lock file as it will update some other packages as well.
Create file at root directory with name "auth.json"
copy your nova credentials to it
{
"http-basic": {
"nova.laravel.com": {
"username": "email",
"password": "passsword"
}
}
}
composer update

AWX Failing to install requirements from private repo

I have an AWX installation with a project. The project is fetched perfectly from the private git repo.
The project has a requirements file which is executed by AWX. The requirements file contains private repositories like this:
- src: git+http://gitlab.test.com/ansible/test.git
version: master
name: test
This however fails with the following error:
test was NOT installed successfully: - command git clone failed in directory.
How can I configure AWX to use the git credentials that are in place already in awx?
It seems like AWX works 'smarter' than I thought it would.
In this case, AWX used the same credentials that it used to fetch the project in the first place. I had two options to resolve this:
Change the links to work via git
Update the same git credential and also add the username and password of that git user.

Composer install private repository on IIS by Jenkins CI

I am trying to install composer dependencies from private bitbucket repository by composer install with lines below in composer.json on my IIS server (triggered by Jenkins CI).
"repositories": [
{
"type": "vcs",
"url": "ssh://git#bitbucket.org/company/repo-name.git"
}
],
The result is:
Failed to execute git clone --mirror "ssh://git#bitbucket.org/company/web.git" "C:/Users/myusername/AppData/Local/Composer/vcs/ssh---company-bitbucket.org-repo-name.git/"
Cloning into bare repository 'C:/Users/myusername/AppData/Local/Composer/vcs/ssh---company-bitbucket.org-repo-name.git'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Is it possible to link private.ppk with composer without need of ssh-agent?
Jenkins CI is logged in as sysuser, so navigate to its .ssh folder and edit config file : C:\Windows\System32\config\systemprofile.ssh\config (if "config" file not exists, create it)
Store your key to e.g. keys subfolder: C:\Windows\System32\config\systemprofile.ssh\keys\bitbucket
In config file add these lines:
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/keys/bitbucket

How to deploy parse dashboard to heroku

I have deployed the parse server on heroku (https://github.com/ParsePlatform/parse-server) but can't find anything to deploy the parse dashboard on heroku. Any reference is appreciated!!
You shouldn't have to clone the parse-dashboard repository. Here is a better way using parse-dashboard as a node module.
Create a new node app:
mkdir my-parse-dashboard
cd my-parse-dashboard
npm init
Fill out the details it asks for.
Create a git repository:
git init
Additionally you can push this git repository to a remote server (e.g. Bitbucket). Note this repository should be private since it will contain your master key.
Install the parse-dashboard package:
npm install parse-dashboard --save
Create an index.js file with the following line:
require('parse-dashboard/Parse-Dashboard/index.js');
Create a parse-dashboard-config.json file which looks like this:
{
"apps": [
{
"serverURL": "your parse server url",
"appId": "your app Id",
"masterKey": "your master key",
"appName": "My Parse App"
}
],
"users": [
{
"user":"username",
"pass":"password"
}
]
}
Update your package.json file and add this section (or modify it if it already exists):
"scripts": {
"start": "node ./index.js --config ./parse-dashboard-config.json --allowInsecureHTTP=1"
}
Note: The allowInsecureHTTP flag seems to be required on Heroku. Thanks to #nsarafa for this.
Commit all your changes and merge them into master.
Create a new Heroku app: heroku apps:create my-parse-dashboard
Run git push heroku master to deploy your app to Heroku.
Remember to generate a strong password as your dashboard is accessible to anyone on the internet. And make the dashboard only accessible through SSL else your password will be sent in clear text. Read this tutorial on how to force all traffic over SSL on Heroku with Cloudflare for your domain.
I just managed to get this working. Here are the steps I took.
Clone parse-dashboard to your local machine.
Run npm install inside that directory.
Update package.json and change the "start" script to:
"start": "node ./Parse-Dashboard/index.js --config ./Parse-Dashboard /parse-dashboard-config.json --allowInsecureHTTP=1"
(Thanks to nsarafa's answer above for that).
Edit your .gitignore file and remove the following three lines:
bundles/Parse-Dashboard/public/bundles/Parse-Dashboard/parsedashboard-config.json
Edit your config file in Parse-Dashboard/parse-dashboard-config.json, making sure URLs and keys are correct. Here is an example :
{
"apps": [
{
"serverURL": "https://dhowung-fjird-52012.herokuapp.com/parse",
"appId": "myAppId",
"masterKey": "myMasterKey",
"appName": "dhowung-fjird-40722"
}
],
"users": [
{
"user":"myUserName",
"pass":"Str0ng_?Passw0rd"
}
]
}
Remove the cache from your heroku parse server app :
heroku config:set NODE_MODULES_CACHE=false --app yourHerokuParseServerApp
if we follow the example above
yourHerokuParseServerApp = dhowung-fjird-40722
(Again, thanks to nsarafa).
Add, commit and push your changes.
Deploy to Heroku again using their CLI or the dashboard.
Step 4 was the key for me because I wasn't committing my config file, and it took me a while to realise.
Also, as stated above, make sure you have user logins and passwords in your config file, following the parse-dashboard docs:
PS: on your heroku parse server make sure your SERVER_URL looks like this https://yourHerokuParseServerAppName.herokuapp.com/parse
Update brew brew update
Install heroku-cli brew install heroku-toolbelt
Login via command line with your heroku credentials heroku login
Make sure your app is there heroku list and note YOURHEROKUAPPSNAME containing the parse-dashboard deployment
Tell Heroku to ignore the cache from previous deploys heroku config:set NODE_MODULES_CACHE=false --app YOURHEROKUAPPSNAME
Go to your package.json and change start: node ./Parse-Dashboard/index.js to start node./Parse-Dashboard/index.js --config ./Parse-Dashboard/parse-dashboard-config.json --allowInsecureHTTP=1"
Delete your Procfile rm Procfile
Add, commit and merge to your master branch
Run git push heroku master
The start script inside your package.json overrides whatever you declare inside of the Procfile. This process should enable a clean deploy to Heroku. Please be cautious and generate user logins with strong passwords before performing this deployment per the parse-dashboard documentation.

Satis - not able to auth repository

I have followed the instructions at http://getcomposer.org/doc/articles/handling-private-packages-with-satis.md to setup Satis.
I got to
php bin/satis build satis.json ./
but then get the following error:
[Composer\Downloader\TransportException]
The 'https://bitbucket.org/api/1.0/repositories/companyName/myPackageName/tags' URL could not be accessed: HTTP/1.1 403 FORBIDD
EN
im guessing this is because its a private repository. Anyone know how to get around this?
My satis.json:
{
"name": "Name Of Package",
"homepage": "https://bitbucket.org/companyName/packageName",
"repositories": [
{ "type": "vcs", "url": "https://bitbucket.org/companyName/packageName" }
],
"require-all": true
}
I suppose you are on your local machine where you already have access to that bitbucket repository.
Use the same URL that is used in your repository as the bitbucket remote location. If HTTPS does not work, try SSH instead.
Note that you have to run the Satis update on your local machine. If some other machine should run it, this machine also needs authenticated access to the bitbucket repository. Depending on your needs, you could share your private key on that machine, or create a new read-only account (Satis does not need to write).

Resources