Skip to content

Deploy to development by rheber #22

Deploy to development by rheber

Deploy to development by rheber #22

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: "Deployment environment"
type: choice
required: true
default: "development"
options:
- development
- production
run-name: Deploy to ${{ github.event.inputs.environment }} by ${{ github.actor }}
permissions:
id-token: write # Allow connections to AWS
contents: write # Allow commit
jobs:
deploy:
name: Deploy to ${{ github.event.inputs.environment }}
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v3
- uses: php-actions/phpunit@v9
with:
configuration: tests/phpunit.xml
- name: Merge Back (prod-only)
if: github.event.inputs.environment == 'production'
run: |
export VERSION=$(python next-version.py < VERSION)
echo $VERSION > VERSION
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git commit -m 'Version bump'
git push
git tag -a $VERSION -m 'Build from CI service'
git push --tags
awk "NR==5{print \"Version: ${VERSION}\"}1" spiff-connect/spiff-connect.php > tmp && mv tmp spiff-connect/spiff-connect.php
- name: Set Env Vars
run: python replace-env-vars.py ${{github.event.inputs.environment}} > tmp && mv tmp spiff-connect/spiff-connect.php
- name: Pull API File
run: |
[[ ${{ github.event.inputs.environment }} = "development" ]] && API_URL='https://assets.app.dev.spiff.com.au/api.js' || API_URL='https://assets.spiff.com.au/api.js'
curl $API_URL > spiff-connect/public/js/api.js
- name: Make Zip File
run: |
[[ ${{ github.event.inputs.environment }} = "development" ]] && ZIP_NAME='spiff-connect-dev' || ZIP_NAME='spiff-connect'
mkdir zip-dir
zip -r - spiff-connect > zip-dir/$ZIP_NAME.zip
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
# Give the session a unique name, like: spiffdev/editor-development-123456789
role-session-name: woo-${{ github.event.inputs.environment }}-${{ github.run_id }}
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy to S3
run: |
[[ ${{ github.event.inputs.environment }} = "development" ]] && ZIP_NAME='spiff-connect-dev' || ZIP_NAME='spiff-connect'
aws s3 cp ./zip-dir/$ZIP_NAME.zip s3://${{ vars.BUCKET_NAME }}
- name: Commit to Subversion Repo (prod-only)
if: github.event.inputs.environment == 'production'
run: |
export VERSION=$(cat VERSION)
svn co https://plugins.svn.wordpress.org/spiff-3d-product-customizer svn-repo
cd svn-repo
cp -r ../spiff-connect/* trunk/
svn add trunk/* || echo 'Added some targets that are already under version control.'
cp -r ../assets/* assets/
svn add assets/* || echo 'Added some targets that are already under version control.'
svn --username ${{ secrets.SVN_CREDS_USR }} --password ${{ secrets.SVN_CREDS_PSW }} ci -m "Version ${VERSION}"
svn cp trunk tags/${VERSION}
svn --username ${{ secrets.SVN_CREDS_USR }} --password ${{ secrets.SVN_CREDS_PSW }} ci -m "Tag Version ${VERSION}"