Skip to content

Merge pull request #769 from PrestaShopCorp/feat/force-clear-module-c… #5494

Merge pull request #769 from PrestaShopCorp/feat/force-clear-module-c…

Merge pull request #769 from PrestaShopCorp/feat/force-clear-module-c… #5494

Workflow file for this run

name: Build & Release draft
on:
pull_request:
push:
branches:
- master
- 2.4.x
- 3.1.x
jobs:
deploy:
name: build dependencies & create artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: 'actions/checkout@v4'
with:
path: ''
- name: Install composer dependencies
run: composer install --no-dev -o
- name: Clean-up project
uses: PrestaShopCorp/[email protected]
- name: Cache module folder
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
upload_asset_preproduction:
runs-on: ubuntu-latest
needs: [ deploy ]
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- name: Retrieve from cache module folder
id: retrieve-cache
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
- name: Check if retrieved from cache was successful
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: exit 1
- name: Manually perform GCP CLI authentication
run: |
echo $GOOGLE_JSON_CRED > token.json
gcloud auth activate-service-account --key-file=token.json
rm token.json
env:
GOOGLE_JSON_CRED: ${{ secrets.G_CREDENTIAL_PREPRODUCTION }}
- name: Copy env files
run: |
gcloud secrets versions access latest --project distribution-preprod --secret=mbo-module-env-3x > .env
rm -f .env.dist
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PREPRODUCTION }}
- name: Prepare the zip
run: |
cd ..
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Create & upload artifact for preprod
uses: 'actions/upload-artifact@v4'
with:
name: ${{ github.event.repository.name }}.preprod
path: /home/runner/work/ps_mbo/${{ github.event.repository.name }}.zip
upload_release_asset_production:
name: Upload the production zip asset to the release
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: deploy
steps:
- name: Retrieve from cache module folder
id: retrieve-cache
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
- name: Check if retrieved from cache was successful
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: exit 1
- name: Manually perform GCP CLI authentication
run: |
echo $GOOGLE_JSON_CRED > token.json
gcloud auth activate-service-account --key-file=token.json
rm token.json
env:
GOOGLE_JSON_CRED: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
- name: Copy env files
run: |
rm -f .env.dist
gcloud secrets versions access latest --project distribution-production-308520 --secret=mbo-module-env-3x > .env
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
- name: Remove test settings files
run: |
rm -f ./src/Traits/HaveConfigurationPage.php
sed -i '/HaveConfigurationPage/d' ps_mbo.php
- name: Create & upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: /home/runner/work/ps_mbo/
update_release_draft:
runs-on: ubuntu-latest
needs: [upload_release_asset_production]
if: github.event_name == 'push'
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ github.event.repository.name }}
- id: release_info
uses: toolmantim/release-drafter@v5
with:
config-name: release-drafter-3x.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare for Release
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- 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 }}/${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip