To securely store your Forge API token in Travis CI, you can follow these steps:
1. Generate a Forge API Token:
- Log in to your Forge account and navigate to the "API" section.
- Generate a new API token that you will use for your Travis CI deployment.
2. Encrypt the Forge API Token:
- Install the Travis CI command-line client by following the instructions in the Travis CI documentation.
- Run the following command to encrypt your Forge API token:
travis encrypt FORGE_API_TOKEN="your_forge_api_token" --add
This will add the encrypted environment variable to your `.travis.yml` file.
3. Configure Travis CI for Forge Deployment:
- In your `.travis.yml` file, add the following steps to your deployment process:
yaml
deploy:
provider: script
script:
- composer global require laravel/forge-cli
- forge server:switch your_server_name
- forge deploy your_site_name.com
on:
branch: main
- Replace `your_server_name` and `your_site_name.com` with the appropriate values for your Forge server and site.
4. Provide SSH Access to Travis CI:
- In addition to the Forge API token, Travis CI also needs SSH access to your Forge server to deploy your application.
- You can add the SSH private key as an encrypted environment variable to your `.travis.yml` file using the same `travis encrypt` command:
travis encrypt SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" --add
- Make sure to replace `~/.ssh/id_rsa` with the path to your SSH private key file.
By following these steps, you can securely store your Forge API token and provide the necessary SSH access to Travis CI, allowing it to automatically deploy your Laravel application to Forge.
Remember, it's important to keep your Forge API token and SSH private key secure, as they provide access to your Forge account and server. Avoid storing them in plain text or committing them to your repository.
Citations:[1] https://community.developer.atlassian.com/t/what-is-the-best-way-to-store-and-access-user-tokens-securely-and-safely/51730
[2] https://stackoverflow.com/questions/56036063/how-to-set-github-token-on-travis-ci-in-a-secure-way
[3] https://docs.travis-ci.com/legal/security/
[4] https://stackoverflow.com/questions/9338428/using-secret-api-keys-on-travis-ci
[5] https://forge.laravel.com/docs/sites/deployments.html