Skip to content

Add support for WooCommerce Checkout Blocks #422

Add support for WooCommerce Checkout Blocks

Add support for WooCommerce Checkout Blocks #422

Workflow file for this run

name: 'Deployment'
# Only trigger, when the build workflow succeeded
on:
# workflow_run:
# workflows: ["PHP Code Analysis"]
# types:
# - completed
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-20.04
outputs:
ip: ${{ steps.expose_ip.outputs.ip}}
steps:
# Configure AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
mask-aws-account-id: true
# Checkout plugin-infrastructure repository to the GitHub Actions runner
- uses: actions/checkout@v4
with:
repository: AltaPay/plugin-infrastructure
token: ${{ secrets.ACCESS_TOKEN }}
ref: 'main'
# Install version 1.0.8 of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.0.8
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
working-directory: provision/plugins
# Select a Terraform workspace
- name: Terraform workspace
run: terraform workspace select wordpress
working-directory: provision/plugins
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform plan
working-directory: provision/plugins
# Run Terraform Apply
# On push to main, build or change infrastructure according to Terraform configuration files
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
- name: Terraform Apply
#if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -var ec2_type=t3.micro -auto-approve
working-directory: provision/plugins
# Add a sleep of 20 seconds, in case instance needs to warm up
- name: Sleep for 20 seconds
uses: jakejarvis/wait-action@master
with:
time: '20s'
# Setting branch name for running cypress tests
- name: Set env TEST_BRANCH_NAME
run: |
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
echo "TEST_BRANCH_NAME=${{ github.head_ref }}" >> "$GITHUB_ENV"
else
echo "TEST_BRANCH_NAME=main" >> "$GITHUB_ENV"
fi
#Run Ansible playbook
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: wordpress.yml
directory: deploy/plugins
key: ${{secrets.SSHKEY}}
options: |
-u ubuntu
-i inventory
--extra-vars "branch_name=${{env.TEST_BRANCH_NAME}} gatewayURL=${{ secrets.GATEWAYURL }} gatewayUser=${{ secrets.GATEWAYUSER }} gatewayPass=${{ secrets.GATEWAYPASS }} wp_user=${{secrets.CMS_ADMIN_USER}} wp_pass=${{secrets.CMS_ADMIN_PASS}} wp_email=${{secrets.CMS_ADMIN_EMAIL}}"
# Export IP for use in cypress tests config
- name: Export IP
run: |
testvar=$(sed '4!d' inventory)
echo $testvar
echo "IP=$testvar">> $GITHUB_ENV
echo $IP
working-directory: deploy/plugins
- name: Expose IP
id: expose_ip
run: echo "ip=${{ env.IP }}" >> $GITHUB_OUTPUT
cypress:
name: 'Cypress'
runs-on: ubuntu-latest
needs: terraform
steps:
# Run Cypress tests
- uses: actions/checkout@v4
with:
ref: '${{env.TEST_BRANCH_NAME}}'
- name: Create Cypress fixture config json
id: create-json-2 # Second ID
uses: jsdaniell/create-json@v1.2.2
with:
name: "config.json"
json: '{"shopURL": "http://${{ needs.terraform.outputs.ip }}/wordpress","adminURL": "http://${{ needs.terraform.outputs.ip }}/wordpress/wp-admin","adminUsername": "${{secrets.CMS_ADMIN_USER}}","adminPass": "${{secrets.CMS_ADMIN_PASS}}", "CC_TERMINAL_NAME": "${{secrets.CC_TERMINAL_NAME}}", "KLARNA_DKK_TERMINAL_NAME": "${{secrets.KLARNA_DKK_TERMINAL_NAME}}", "iDEAL_EUR_TERMINAL": "${{secrets.IDEAL_EUR_TERMINAL_NAME}}"}'
dir: "tests/integration-test/cypress/fixtures/"
- name: Install Cypress
run: npm i
working-directory: "tests/integration-test"
- name: Run Cypress tests
run: ./node_modules/.bin/cypress run --config video=false
working-directory: "tests/integration-test"
# after the test run completes
# store screenshots
# NOTE: screenshots will be generated only if E2E test failed
- uses: actions/upload-artifact@v3
if: failure() || true
with:
name: cypress-screenshots
path: "./tests/integration-test/cypress/screenshots"
if-no-files-found: ignore