feat: Update workflow #193
This file contains 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: Deploy | |
on: | |
push: | |
branches: | |
- dev | |
- stg | |
- main | |
pull_request: | |
types: | |
closed | |
branches: | |
- dev | |
- stg | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true || github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.1' | |
extensions: pdo, mysql | |
- name: Install Composer dependencies | |
run: composer install --no-dev --optimize-autoloader | |
- name: Create .env file | |
run: | | |
touch .env | |
echo "APP_KEY=base64:$(php artisan key:generate --show)" >> .env | |
echo "DB_CONNECTION=mysql" >> .env | |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env | |
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env | |
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env | |
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
- name: Download gh-ost binary | |
run: | | |
wget https://github.com/github/gh-ost/releases/download/v1.1.7/gh-ost-binary-linux-amd64-20241219160321.tar.gz | |
tar -xvf gh-ost-binary-linux-amd64-20241219160321.tar.gz | |
sudo mv gh-ost /usr/local/bin/ # Move to a directory in PATH | |
sudo chmod +x /usr/local/bin/gh-ost | |
- name: Run gh-ost migrations | |
run: bash gh-ost-with-tracking.sh | |
env: | |
DB_HOST: ${{ secrets.DB_HOST }} | |
DB_PORT: ${{ secrets.DB_PORT }} | |
DB_DATABASE: ${{ secrets.DB_DATABASE }} | |
DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
- name: Show table columns after gh-ost migration | |
run: | | |
mysql -h ${{ secrets.DB_HOST }} -P ${{ secrets.DB_PORT }} -u ${{ secrets.DB_USERNAME }} -p${{ secrets.DB_PASSWORD }} ${{ secrets.DB_DATABASE }} -e "DESCRIBE users;" | |
mysql -h ${{ secrets.DB_HOST }} -P ${{ secrets.DB_PORT }} -u ${{ secrets.DB_USERNAME }} -p${{ secrets.DB_PASSWORD }} ${{ secrets.DB_DATABASE }} -e "SELECT * FROM migrations;" | |