-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,82 @@ | ||
name: Deploy | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Deployment environment" | ||
type: choice | ||
required: true | ||
default: "development" | ||
options: | ||
- development | ||
- production | ||
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 | ||
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 | ||
deploy: | ||
name: Deploy to ${{ github.event.inputs.environment }} | ||
runs-on: ubuntu-latest | ||
environment: ${{ github.event.inputs.environment }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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: 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: 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.aumelbdev.spiffcommerce.com/api.js' || API_URL='https://assets.us.spiffcommerce.com/shopify.js' | ||
curl $API_URL > spiff-connect/public/js/api.js | ||
- name: Pull API File | ||
run: | | ||
[[ ${{ github.event.inputs.environment }} = "development" ]] && API_URL='https://assets.aumelbdev.spiffcommerce.com/api.js' || API_URL='https://assets.us.spiffcommerce.com/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: 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: 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: 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}" | ||
- 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}" |