diff --git a/.circleci/.circleci.yml b/.circleci/.circleci.yml new file mode 100644 index 00000000..91904ed6 --- /dev/null +++ b/.circleci/.circleci.yml @@ -0,0 +1,163 @@ +# Notes: +# - Jobs initially start from /home/circleci/project +# - Plugin located at /home/circleci/project/wp-graphql-content-blocks + +version: 2.1 + +orbs: + php: circleci/php@1.1.0 + wp-product-orb: wpengine/wp-product-orb@2.0.0 + node: circleci/node@5.2.0 + +jobs: + plugin-unzip: + executor: wp-product-orb/default + environment: + WPE_SESSION_DIR: ./.wpe + parameters: + slug: + type: string + filename: + type: string + steps: + - attach_workspace: + at: . + - wp-product-orb/variable_load + - run: + name: "Unzip plugin files" + command: | + cd ~/project + mkdir build + curl -sL https://github.com/wpengine/wp-graphql-content-blocks/releases/latest/download/wp-graphql-content-blocks.zip > <>.zip + unzip -o -d <> <>.zip + ls -laR + - wp-product-orb/get_version_from_php: + filename: <>/<> + return_var: BUILD_VERSION + - wp-product-orb/variable: + var: BUILD_VERSION + value: $BUILD_VERSION + - run: + name: "Move zip file to build directory" + command: | + mv <>.zip build/<>.$BUILD_VERSION.zip + - run: + name: "DEBUG" + command: | + ls -laR + - persist_to_workspace: + root: . + paths: + - . + + plugin-build-json: + executor: wp-product-orb/parser + environment: + WPE_SESSION_DIR: ./.wpe + parameters: + slug: + type: string + steps: + - attach_workspace: + at: . + - run: + command: | + cd ~/project + - wp-product-orb/variable_load + - wp-product-orb/parse_wp_readme: + infile: <>/readme.txt + outfile: build/<>.$BUILD_VERSION.json + - store_artifacts: + path: build + - run: + name: "DEBUG" + command: | + pwd + ls -laR + - persist_to_workspace: + root: . + paths: + - build + + plugin-deploy: + executor: wp-product-orb/authenticate + environment: + WPE_SESSION_DIR: ./.wpe + parameters: + auth_url: + type: string + upload_url: + type: string + slug: + type: string + steps: + - attach_workspace: + at: . + - wp-product-orb/variable_load + - wp-product-orb/authenticate: + user: WPE_LDAP_USER + pass: WPE_LDAP_PASS + url: <> + - run: + name: "DEBUG" + command: | + pwd + ls -laR + - wp-product-orb/post_zip: + url: <>/<> + zip: build/<>.$BUILD_VERSION.zip + json: build/<>.$BUILD_VERSION.json + version: $BUILD_VERSION + +workflows: + deploy: + jobs: + - plugin-unzip: + slug: wpgraphql-content-blocks + filename: wp-graphql-content-blocks.php + # Run this job when a tag is published. + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ + - plugin-build-json: + slug: wpgraphql-content-blocks + requires: + - plugin-unzip + # Run this job when a tag is published. + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ + - plugin-deploy: + name: "plugin-deploy-staging" + slug: wpgraphql-content-blocks + requires: + - plugin-unzip + - plugin-build-json + filters: + branches: + only: + - main + - canary + tags: + only: /^v.*/ + context: wpe-ldap-creds + auth_url: https://auth-staging.wpengine.io/v1/tokens + upload_url: https://wp-product-info-staging.wpesvc.net/v1/plugins + - plugin-deploy: + name: "plugin-deploy-production" + slug: wpgraphql-content-blocks + requires: + - "plugin-deploy-staging" + filters: + branches: + ignore: /.*/ + tags: + # Run this job when a tag is published. + only: /^v.*/ + context: wpe-ldap-creds + auth_url: https://auth.wpengine.io/v1/tokens + upload_url: https://wp-product-info.wpesvc.net/v1/plugins