pipelines:
  tags:
    '*':
      - step:
          name: WP TRANSACTIONS | Deployment
          image: php:7.4
          script:
            # Deps
            - apt-get update && apt-get install -y subversion
            - apt-get update && apt-get install -y git

            # Clone Plugin SVN
            - svn co https://plugins.svn.wordpress.org/wp-transactions/ /tmp/wp-transactions
            - cd /tmp/wp-transactions/trunk

            # Set up PHP CS
            - curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
            - chmod +x phpcs.phar
            - mv phpcs.phar /usr/local/bin/phpcs

            # Install WordPress coding standards
            - git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git /tmp/wpcs
            - /usr/local/bin/phpcs --config-set installed_paths /tmp/wpcs

            # Copy the current files to SVN
            - cp -r /opt/atlassian/pipelines/agent/build/* .

            # Run PHPCS checks on the code
            # - phpcs --standard=WordPress --extensions=php .

            # Commit to SVN
            - svn add --force * --auto-props --parents --depth infinity -q
            - svn commit -m "${BITBUCKET_TAG}" --username $SVN_USERNAME --password $SVN_PASSWORD

            # Create SVN tag
            - cd /tmp/wp-transactions/tags
            - svn copy https://plugins.svn.wordpress.org/wp-transactions/trunk https://plugins.svn.wordpress.org/wp-transactions/tags/${BITBUCKET_TAG} --username $SVN_USERNAME --password $SVN_PASSWORD -m "Creating tag for ${BITBUCKET_TAG}"
