-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secrets/deploy.yml Location & NPM Commands #29
Comments
Perhaps I need to something like mentioned at #4 name: Deploy
on:
# Run on pushes to `staging` branch only.
push:
paths-ignore:
- '**.md'
branches:
- staging
- '!main'
# Allow manually triggering the workflow. Used for production deploy
workflow_dispatch:
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4]
node: [12.x]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: PHP setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, deployer, wp-cli
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Deploy to staging
if: ${{ github.ref == 'refs/heads/staging' }}
uses: deployphp/action@master
with:
private-key: ${{ secrets.STAGING_KEY }}
dep: deploy ${{ secrets.ADMIN_USER }} ${{ secrets.ADMIN_EMAIL }} ${{ secrets.ADMIN_PASSWORD }} staging -v
- name: Deploy to production
if: ${{ github.ref == 'refs/heads/main' }}
uses: deployphp/action@master
with:
private-key: ${{ secrets.PRODUCTION_KEY }}
dep: deploy ${{ secrets.ADMIN_USER }} ${{ secrets.ADMIN_EMAIL }} ${{ secrets.ADMIN_PASSWORD }} production Just not sure how name: deploy
on: push
# It is important to specify "concurrency" for the workflow,
# to prevent concurrency between different deploys.
concurrency: production_environment
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: Deploy
uses: deployphp/action@v1
with:
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy |
Secret come from girl ha s had js ssh |
@antonmedv Not quite certain what you mean here.. You mean that Would be nice to have the README example steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: PHP setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, deployer, wp-cli
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }} Is useful, but again I wonder what |
Yes this can be loaded from the github secrets this is like a special field in settings with the hub |
And for simple environment variables can be also just need to assign environment variable from the stickers and of course go to settings of your repository and seconds down. |
On using build matrices I found an explanation here https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs and example strategy:
matrix:
node: [10, 12, 14]
steps:
# Configures the node version used on GitHub-hosted runners
- uses: actions/setup-node@v2
with:
# The Node.js version to configure
node-version: ${{ matrix.node }} Thanks to @antonmedv feedback and some more reading I am slowly starting to understand. Thanks Anton! |
Got this now name: deploy
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
push:
branches:
- master
pull_request:
branches:
- master
concurrency: production_environment
# on: push
# It is important to specify "concurrency" for the workflow,
# to prevent concurrency between different deploys.
# concurrency: production_environment
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1]
node: [14.x]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: PHP setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, deployer
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
run: npm install
run: npm run prod
- name: Deploy
uses: deployphp/action@v1
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy But hitting
and it ran right away, which I did not really want... perhaps I need to change the branch as well. |
Looks yaml file has some different from different spaces instant before run |
@antonmedv was true on some of the spacing but running name: deploy
on:
# Run on pushes to `staging` branch only.
push:
paths-ignore:
- '**.md'
branches:
- staging
- '!main'
# Allow manually triggering the workflow. Used for production deploy
workflow_dispatch:
concurrency: production_environment
# on: push
# It is important to specify "concurrency" for the workflow,
# to prevent concurrency between different deploys.
# concurrency: production_environment
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1]
node: [14.x]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: PHP setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, deployer
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
run: npm install
# run: npm run prod
# npm:run:prod:
# - run: 'cd {{release_path}} && npm run prod'
- name: Deploy to staging
if: ${{ github.ref == 'refs/heads/staging' }}
uses: deployphp/action@master
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy
- name: Deploy to production
if: ${{ github.ref == 'refs/heads/master' }}
uses: deployphp/action@master
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy |
Checking https://gist.github.com/cagartner/27052b0bccb99c74d8616a943426b390 I might need - run: npm install
- run: npm run prod
# npm:run:prod:
# - run: 'cd {{release_path}} && npm run prod' but wonder if I need to change path inside the image and if all this then adds assets to repository. Not sure yet. |
Well, perhaps I need to use this block - name: Commit built assets
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy in my ci.yml action as well: name: deploy
on:
# Run on pushes to `staging` branch only.
push:
paths-ignore:
- '**.md'
branches:
- staging
- '!main'
# Allow manually triggering the workflow. Used for production deploy
workflow_dispatch:
concurrency: production_environment
# on: push
# It is important to specify "concurrency" for the workflow,
# to prevent concurrency between different deploys.
# concurrency: production_environment
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1]
node: [14.x]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: PHP setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2, deployer
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run production
- name: Commit built assets
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy
- name: Deploy to staging
if: ${{ github.ref == 'refs/heads/staging' }}
uses: deployphp/action@master
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy
- name: Deploy to production
if: ${{ github.ref == 'refs/heads/master' }}
uses: deployphp/action@master
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy Question remains though... if I build these assets on the image/github do these github acctions including push also happen on Github? @antonmedv Do you build locally? Or do you add it to |
Yes you can simply Luther and then upload it to destination this is what I do and you can do it both ways I prefer to do from the plural |
@antonmedv think you made typo there. What do you mean by "Luther then upload it to destination"? You build on Github using a Github action like I am suggesting here? I mean like:
Or do you do more on Github action?
import:
- recipe/laravel.php
- contrib/php-fpm.php
- contrib/npm.php
config:
application: 'our-app'
remote_user: forge
deploy_path: '~/{{hostname}}'
repository: '[email protected]:app/our-app.git'
php_fpm_version: '8.0'
keep_releases: '10'
shared_files:
- '.env'
- '.transip_private_key'
- 'storage/app/exact.api.json'
shared_dirs:
- 'bootstrap/cache'
- 'public/uploads'
- 'public/published'
- 'storage/framework/cache'
- 'storage/framework/sessions'
- 'storage/framework/views'
- 'storage/logs'
- 'storage/tls'
- 'storage/app/downloads'
- 'storage/app/modules'
- 'storage/app/public'
writable_dirs:
- 'public/uploads'
- 'public/published'
- 'storage/framework/cache/data'
- 'storage/logs'
- 'storage/tls'
- 'storage/app/downloads'
- 'storage/app/modules'
- 'storage/app/public'
hosts:
prod:
hostname: 'site.com'
staging:
hostname: 'staging.site.com'
tasks:
deploy:
- deploy:prepare
- deploy:vendors
- artisan:storage:link
- artisan:view:cache
- artisan:config:cache
- artisan:optimize
- artisan:migrate
- npm:install
- npm:run:prod
- artisan:queue:restart
- artisan:horizon:terminate
- deploy:publish
npm:run:prod:
- run: 'cd {{release_path}} && npm run prod'
after:
deploy:symlink: php-fpm:reload
deploy:failed: deploy:unlock |
Found some code at https://gist.github.com/cagartner/27052b0bccb99c74d8616a943426b390 for building including name: CD
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.PUSH_TOKEN }}
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm install
- run: npm run production
- name: Commit built assets
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy
- name: Deploy
uses: deployphp/action@v1
with:
# Private key for connecting to remote hosts. To generate private key:
# `ssh-keygen -o -t rsa -C '[email protected]'`.
# Required.
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy Well it is at least closer again. Just do not follow import:
- recipe/laravel.php
- contrib/php-fpm.php
- contrib/npm.php
config:
application: 'app-app'
remote_user: forge
deploy_path: '~/{{hostname}}'
repository: '[email protected]:app/app-app.git'
php_fpm_version: '8.0'
keep_releases: '10'
shared_files:
- '.env'
- '.transip_private_key'
- 'storage/app/exact.api.json'
shared_dirs:
- 'bootstrap/cache'
- 'public/uploads'
- 'public/published'
- 'public/images'
- 'public/downloads'
- 'storage/framework/cache'
- 'storage/framework/sessions'
- 'storage/framework/views'
- 'storage/logs'
- 'storage/tls'
- 'storage/app/downloads'
- 'storage/app/modules'
- 'storage/app/public'
writable_dirs:
- 'public/uploads'
- 'public/published'
- 'storage/framework/cache/data'
- 'storage/logs'
- 'storage/tls'
- 'storage/app/downloads'
- 'storage/app/modules'
- 'storage/app/public'
hosts:
prod:
hostname: 'app.com'
staging:
hostname: 'staging.app.com'
tasks:
deploy:
- deploy:prepare
- deploy:vendors
- artisan:storage:link
- artisan:view:cache
- artisan:config:cache
- artisan:optimize
- artisan:migrate
# - npm:install
# - npm:run:prod
- artisan:queue:restart
- artisan:horizon:terminate
- deploy:publish
# npm:run:prod:
# - run: 'cd {{release_path}} && npm run prod'
after:
deploy:symlink: php-fpm:reload
deploy:failed: deploy:unlock |
When I use this action, can I keep
deploy.yml
:in the root of the Laravel/Vue project?
Two, where do we add the secrets?
Three, will the action
run npm install
andnpm run prod
inside the image as well? I mean, I can add this to the deploy.yml but better to get that done in the image/ on Github and then deploy like we do now. Only now we build locally.Upvote & Fund
The text was updated successfully, but these errors were encountered: