Skip to content

Commit

Permalink
chore: 👷 test build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
ryntab committed Jun 17, 2024
1 parent baebbd4 commit 4bcdfd1
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- master # or your default branch
pull_request:
branches:
- master # or your default branch

jobs:
build:
Expand All @@ -12,17 +15,35 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Necessary to fetch all history for pushing tags

# Cache Composer dependencies
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

# Set up PHP and Composer
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0' # specify your PHP version
php-version: '8.0'
tools: composer

- name: Install PHP dependencies
run: composer install

# Cache Node.js dependencies
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-

# Set up Node.js and build Nuxt project
- name: Set up Node.js
uses: actions/setup-node@v3
Expand All @@ -39,17 +60,23 @@ jobs:
cd event-viewer
npm run generate
# Commit and push generated Nuxt site
- name: Commit and push generated Nuxt site
run: |
cd event-viewer
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add dist
git commit -m "Update generated Nuxt site"
git push origin master
if: github.ref == 'refs/heads/master' # Only push changes on master

- name: Upload generated Nuxt site
uses: actions/upload-artifact@v3
with:
name: generated-site
path: event-viewer/dist

# If you have any build steps for the PHP project, add them here
# - name: Build PHP project
# run: |
# # Add your PHP build commands here, if any

# Archive PHP project files before uploading
- name: Create archive of PHP project
run: zip -r php-project.zip .
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release PHP and Nuxt Projects

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

# Set up PHP and Composer
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
tools: composer

- name: Install PHP dependencies
run: composer install

# Set up Node.js and build Nuxt project
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Nuxt dependencies
run: |
cd event-viewer
npm install
- name: Generate Nuxt site
run: |
cd event-viewer
npm run generate
- name: Create release artifacts
run: |
cd event-viewer
zip -r generated-site.zip dist
zip -r php-project.zip .
- name: Upload release artifacts
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: event-viewer/generated-site.zip
asset_name: generated-site.zip
asset_content_type: application/zip

- name: Upload PHP project
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: php-project.zip
asset_name: php-project.zip
asset_content_type: application/zip

0 comments on commit 4bcdfd1

Please sign in to comment.