Skip to content

Commit

Permalink
GitHub workflow PS8
Browse files Browse the repository at this point in the history
  • Loading branch information
seiwan committed May 7, 2024
1 parent 8054d70 commit 030e7e7
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 99 deletions.
93 changes: 0 additions & 93 deletions .github/workflows/build-release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jobs:
js-linter:
name: JS linter
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ name: PHP tests
on:
push:
branches:
- 'master'
- 'prestashop/8.x'
- "master"
- "prestashop/8.x"
pull_request:
types: [opened, reopened, synchronize, edited]

jobs:
header-stamp:
name: Check license headers
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"

- name: Cache vendor folder
uses: actions/cache@v1
Expand All @@ -36,9 +37,11 @@ jobs:

- name: Run Header Stamp in Dry Run mode
run: php vendor/bin/header-stamp --license=vendor/prestashop/header-stamp/assets/afl.txt --exclude=.github,node_modules,vendor,tests,_dev --dry-run

php-linter:
name: PHP Syntax check 7.2|7.3|7.4
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -48,20 +51,24 @@ jobs:
uses: prestashop/github-action-php-lint/7.3@master
- name: PHP syntax checker 7.4
uses: prestashop/github-action-php-lint/7.4@master

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/[email protected]
- name: Run PHP-CS-Fixer
uses: prestashopcorp/github-action-php-cs-fixer@master

phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['8.0.0', 'latest']
presta-versions: ["8.0.0", "latest"]
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -83,19 +90,21 @@ jobs:
- name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }})
run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }}

- name : Run PHPStan
- name: Run PHPStan
run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/phpstan-PS-8.neon --error-format github

phpunit:
name: PHPUnit
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ready to review')
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"

- name: Cache vendor folder
uses: actions/cache@v1
Expand Down
200 changes: 200 additions & 0 deletions .github/workflows/ps8-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: PrestaShop 8 - Build & Release draft

on:
pull_request:
types: [opened, reopened, synchronize, edited, labeled]
push:
tags:
- "v8.*"
branches:
- "prestashop/8.x"

env:
ZIP_NAME_INTEGRATION: ${{ github.event.repository.name }}-integration-pr${{ github.event.number }}
ZIP_NAME_PREPRODUCTION: ${{ github.event.repository.name }}-preproduction-pr${{ github.event.number }}
ZIP_NAME_PRODUCTION: ${{ github.event.repository.name }}-${{ github.ref_name }}

jobs:
deploy_integration:
name: INTEGRATION - Build dependencies & create artifact
runs-on: ubuntu-latest
if:
contains(github.event.pull_request.labels.*.name, 'integration deployment') &&
contains(github.event.pull_request.labels.*.name, 'ps8')

steps:
- name: Checkout the repository 🎁
uses: actions/checkout@v4

- name: Auth GCP
uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1
with:
auth-mode: "workload-federation"
provider: ${{ secrets.WI_PROVIDER_INTEGRATION }}
service-account: ${{ secrets.WI_SA_INTEGRATION }}
registry-login: true

- name: Write .env file
run: gcloud beta secrets versions access latest --project=$GCP_PROJECT --secret="module-env" > .env
env:
GCP_PROJECT: ${{ secrets.GCP_PROJECT_INTEGRATION }}

- name: Build JS dependencies
uses: PrestaShopCorp/github-action-build-js/[email protected]
with:
cmd: npm
path: ./

- name: Install composer dependencies
run: composer install --no-dev -o

- name: Clean-up project
uses: PrestaShopCorp/[email protected]

- name: Clean-up node_modules directory
run: sudo rm -rf node_modules

- name: Generate zip
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ env.ZIP_NAME_INTEGRATION }}.zip ${{ github.event.repository.name }} -x '*.git*'
- name: Push to GCP bucket storage
shell: bash
run: gsutil cp ${{ env.ZIP_NAME_INTEGRATION }}.zip gs://checkout-assets-integration/zips

deploy_preproduction:
name: PREPRODUCTION - Build dependencies & create artifact
runs-on: ubuntu-latest
if:
contains(github.event.pull_request.labels.*.name, 'preproduction deployment') &&
contains(github.event.pull_request.labels.*.name, 'ps8')

steps:
- name: Checkout the repository 🎁
uses: actions/checkout@v4

- name: Auth GCP
uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1
with:
auth-mode: "workload-federation"
provider: ${{ secrets.WI_PROVIDER_PREPRODUCTION }}
service-account: ${{ secrets.WI_SA_PREPRODUCTION }}
registry-login: true

- name: Write .env file
run: gcloud beta secrets versions access latest --project=$GCP_PROJECT --secret="module-env" > .env
env:
GCP_PROJECT: ${{ secrets.GCP_PROJECT_PREPRODUCTION }}

- name: Build JS dependencies
uses: PrestaShopCorp/github-action-build-js/[email protected]
with:
cmd: npm
path: ./

- name: Install composer dependencies
run: composer install --no-dev -o

- name: Clean-up project
uses: PrestaShopCorp/[email protected]

- name: Clean-up node_modules directory
run: sudo rm -rf node_modules

- name: Generate zip
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ env.ZIP_NAME_PREPRODUCTION }}.zip ${{ github.event.repository.name }} -x '*.git*'
- name: Push to GCP bucket storage
shell: bash
run: gsutil cp ${{ env.ZIP_NAME_PREPRODUCTION }}.zip gs://checkout-assets-preproduction/zips

deploy_production:
name: PRODUCTION - Build dependencies & create artifact
runs-on: ubuntu-latest

steps:
- name: Checkout the repository 🎁
uses: actions/checkout@v4

- name: Auth GCP
uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1
with:
auth-mode: "workload-federation"
provider: ${{ secrets.WI_PROVIDER_PRODUCTION }}
service-account: ${{ secrets.WI_SA_PRODUCTION }}
registry-login: true

- name: Write .env file
run: |
gcloud beta secrets versions access latest --project=$GCLOUD_PROJECT --secret="module-env" > .env
env:
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT_PRODUCTION }}

- name: Build JS dependencies
uses: PrestaShopCorp/github-action-build-js/[email protected]
with:
cmd: npm
path: ./

- name: Install composer dependencies
run: composer install --no-dev -o

- name: Clean-up project
uses: PrestaShopCorp/[email protected]

- name: Clean-up node_modules directory
run: sudo rm -rf node_modules

- name: Create & upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME_PRODUCTION }}
path: ../

update_release_draft_production:
name: PRODUCTION - Update release draft
runs-on: ubuntu-latest
needs: [deploy_production]
if: github.event_name == 'push'

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.ZIP_NAME_PRODUCTION }}

- name: Release drafter
id: release_info
uses: toolmantim/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare for Release
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ env.ZIP_NAME_PRODUCTION }}.zip ${{ github.event.repository.name }} -x '*.git*'
- name: Clean existing assets
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
for asset in $assets
do
bin/hub api -X DELETE $asset
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to GitHub Release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_info.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}/${{ env.ZIP_NAME_PRODUCTION }}.zip
asset_name: ${{ env.ZIP_NAME_PRODUCTION }}.zip
asset_content_type: application/zip

0 comments on commit 030e7e7

Please sign in to comment.