Skip to content

Commit

Permalink
Deployment workflow PS 1.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
seiwan committed Nov 18, 2024
1 parent 084c768 commit 41e6d91
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 38 deletions.
45 changes: 40 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,45 @@ on:
- prestashop/1.7.x

jobs:
zip-name-matrix:
name: Generate zip file name
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
env:
- lower: integration
triggered: ${{ contains(github.event.pull_request.labels.*.name, 'integration deployment') }}
- lower: preproduction
triggered: ${{ contains(github.event.pull_request.labels.*.name, 'preproduction deployment') }}
- lower: production
triggered: ${{ github.event_name == 'push' }}
outputs:
name: ${{ steps.zip-name.outputs.date }}

steps:
- name: Generate zip file name
id: zip-name
if: matrix.env.triggered == true
run: |
zip_name=$REPOSITORY
test_name=''
if [ $ENV != 'production' ]; then
date=$(date -d '+2 hours' +'%Y-%m-%d_%H-%M-%S')
test_name=-$PS_VERSION-$ENV-$PR_NUMBER-$date
fi
echo "zip_name=$zip_name$test_name.zip" >> "$GITHUB_OUTPUT"
env:
ENV: ${{ matrix.env.lower }}
REPOSITORY: ${{ github.event.repository.name }}
PS_VERSION: ps7
PR_NUMBER: pr${{ github.event.number }}

push-to-repository-matrix:
name: ${{ matrix.env.upper }} - Push to GitHub repository
needs: [zip-name-matrix]
strategy:
fail-fast: false
matrix:
Expand All @@ -30,14 +67,13 @@ jobs:
env-upper: ${{ matrix.env.upper }}
env-lower: ${{ matrix.env.lower }}
triggered: ${{ matrix.env.triggered }}
zip-name: ${{ needs.zip-name-matrix.outputs.name }}
repository-name: ${{ github.event.repository.name }}
prestashop-version: ps7
pr-number: pr${{ github.event.number }}
secrets: inherit

push-to-bucket-matrix:
name: ${{ matrix.env.upper }} - Push to GCP bucket storage
needs: [push-to-repository-matrix]
needs: [zip-name-matrix]
strategy:
fail-fast: false
matrix:
Expand All @@ -56,9 +92,8 @@ jobs:
env-upper: ${{ matrix.env.upper }}
env-lower: ${{ matrix.env.lower }}
triggered: ${{ matrix.env.triggered }}
repository-name: ${{ github.event.repository.name }}
zip-name: ${{ needs.zip-name-matrix.outputs.name }}
prestashop-version: ps7
pr-number: pr${{ github.event.number }}
secrets: inherit

update-release-draft:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/push-to-bucket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ on:
triggered:
required: true
type: boolean
repository-name:
zip-name:
required: true
type: string
default: "ps_checkout"
prestashop-version:
required: true
type: string
pr-number:
required: true
type: string

jobs:
current_date:
name: Get current date
Expand All @@ -46,15 +41,13 @@ jobs:
contents: read
pull-requests: write
if: inputs.triggered == true
env:
ZIP_NAME: ${{ inputs.repository-name && (inputs.env-lower != 'production' && '-' && inputs.prestashop-version && '-' && inputs.env-lower && '-pr' && github.event.number && '-' && needs.current_date.outputs.date) }}.zip

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

- name: Push to GCP bucket storage
shell: bash
run: gsutil cp ${{ env.ZIP_NAME }} gs://ps-eu-w1-checkout-assets-${{ inputs.env-lower }}/zips/${{ inputs.prestashop-version }}
run: gsutil cp ${{ inputs.zip-name }} gs://ps-eu-w1-checkout-assets-${{ inputs.env-lower }}/zips/${{ inputs.prestashop-version }}
30 changes: 7 additions & 23 deletions .github/workflows/push-to-repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,15 @@ on:
triggered:
required: true
type: boolean
repository-name:
required: true
type: string
default: "ps_checkout"
prestashop-version:
zip-name:
required: true
type: string
pr-number:
repository-name:
required: true
type: string
default: "ps_checkout"

jobs:
current_date:
name: Get current date
runs-on: ubuntu-latest
if: inputs.triggered == true
outputs:
date: ${{ steps.date.outputs.date }}

steps:
- name: Date
id: date
run: echo "date=$(date -d '+2 hours' +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_OUTPUT"

push-to-repository:
name: ${{ inputs.env-upper }} - Create zip file and push to GitHub repository
runs-on: ubuntu-latest
Expand All @@ -45,8 +30,6 @@ jobs:
contents: read
pull-requests: write
if: inputs.triggered == true
env:
ZIP_NAME: ${{ inputs.repository-name && ((inputs.env-lower != 'production' && '-' && inputs.prestashop-version && '-' && inputs.env-lower && '-pr' && github.event.number && '-' && needs.current_date.outputs.date) || '') }}.zip

steps:
- name: Checkout the repository 🎁
Expand Down Expand Up @@ -81,14 +64,15 @@ jobs:
done
- name: Workaround actions/upload-artifact#176
id: artifacts
run: |
echo "artifacts_path=$(realpath ..)" >> $GITHUB_ENV
echo "path=$(realpath ..)" >> "$GITHUB_OUTPUT"
- name: Create & upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: ${{ env.artifacts_path }}
name: ${{ inputs.zip-name }}
path: ${{ steps.artifacts.outputs.path }}
include-hidden-files: true
retention-days: ${{ (inputs.env-lower == 'production' && 90) || 1 }}

Expand Down

0 comments on commit 41e6d91

Please sign in to comment.