Create production backup #276
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create production backup | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '33 9 * * *' | |
jobs: | |
create-production-backup: | |
runs-on: ubuntu-latest | |
env: | |
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} | |
DEPLOYER_HOSTS: ${{ secrets.DEPLOYER_HOSTS }} | |
steps: | |
- uses: actions/checkout@v5 | |
- name: Cache vendor | |
uses: actions/cache@v4 | |
with: | |
path: | | |
vendor | |
~/.composer/cache | |
key: vendor-${{ hashFiles('**/composer.lock') }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- name: Install dependencies | |
run: | | |
rm -rfv vendor/magento/magento2-base || echo "No Magento 2 Base to remove" | |
composer install --no-interaction --no-progress --no-suggest --prefer-dist | |
- name: Create hosts.yml from secret | |
run: echo "$DEPLOYER_HOSTS" > hosts.yml | |
- name: Dump database | |
uses: deployphp/action@v1 | |
with: | |
dep: database:production:copy stage=production | |
private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Set up AWS credentials | |
uses: aws-actions/configure-aws-credentials@v5 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-central-1 | |
- name: Upload to S3 | |
run: aws s3 cp ./shop.magedispatch.com-backup.sql.gz s3://shop.magedispatch.com/ | |