Skip to content

qa.orcid.org deploy WordPress - post 25422 createArtifact @true #243

qa.orcid.org deploy WordPress - post 25422 createArtifact @true

qa.orcid.org deploy WordPress - post 25422 createArtifact @true #243

Workflow file for this run

name: Homepage qa.orcid.org Deploy
run-name: qa.orcid.org deploy WordPress ${{ inputs.environment }} - post ${{ inputs.postID }} createArtifact @${{ inputs.createArtifact }}
on:
workflow_dispatch:
inputs:
createArtifact:
required: true
description: "Create a versioned artifact?"
type: choice
options:
- 'false'
- 'true'
postID:
required: true
type: string
description: "Wordpress post id to clone"
default: "25422"
jobs:
clone-post:
environment: qa.orcid.org
runs-on: ubuntu-latest
outputs:
script-success: ${{ steps.wordpress-cloning-main.outputs.script-success }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cssutils
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install node dependencies
run: npm install
- name: Run clone and process script
id: wordpress-cloning-main
run: |
if [ "${{ inputs.createArtifact }}" == 'false' ]; then
python wordpress-cloning-main.py STAGING ${{ inputs.postID }} ${{ secrets.WORDPRESS_USERNAME }} ${{ secrets.WORDPRESS_PASSWORD }} --dry-run
else
python wordpress-cloning-main.py STAGING ${{ inputs.postID }} ${{ secrets.WORDPRESS_USERNAME }} ${{ secrets.WORDPRESS_PASSWORD }}
fi
continue-on-error: true
env:
GITHUB_OUTPUT: ${{ github.output }}
GITHUB_STEP_SUMMARY: ${{ github.step_summary }}
- name: Check script success
if: steps.wordpress-cloning-main.outputs.script-success == 'false'
run: |
echo "Script failed, raising an error."
exit 1
- name: Upload HTML to S3
uses: reggionick/s3-deploy@v4
if: ${{ inputs.createArtifact != 'true' }}
with:
folder: dist
bucket: ${{vars.QA_AWS_BUCKET}}
bucket-region: ${{ secrets.AWS_REGION }}
delete-removed: true
no-cache: true
private: true
files-to-include: '{.*/**,**}'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
release_prod_wordpress_new_version:
environment: qa.orcid.org
runs-on: ubuntu-latest
needs: clone-post
if: inputs.createArtifact == 'true' && needs.clone-post.outputs.script-success == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Get the current version tag
id: get_version
run: |
git checkout main
git pull
TAG=$(git tag --sort=-version:refname | head -n 1)
echo "Current version tag: $TAG"
echo "version=${TAG}" >> "$GITHUB_OUTPUT"
- name: Calculate new version
id: new_version
run: |
CURRENT_VERSION=${{ steps.get_version.outputs.version }}
MAJOR=$(echo $CURRENT_VERSION | cut -d'.' -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d'.' -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d'.' -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "New version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Inject version, commit, and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENVIRONMENT: 'STAGING'
run: python wordpress-cloning-version-update.py ${{ steps.new_version.outputs.new_version }}
- name: Create and push tag
run: |
NEW_TAG=${{ steps.new_version.outputs.new_version }}
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.new_version.outputs.new_version }}
release_name: Release ${{ steps.new_version.outputs.new_version }}
draft: false
prerelease: false
upload_prod_wordpress_to_qa_s3:
environment: qa.orcid.org
needs: release_prod_wordpress_new_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get recent changes
run: |
git pull
- name: Upload HTML to S3
uses: reggionick/s3-deploy@v4
with:
folder: dist
bucket: ${{vars.QA_AWS_BUCKET}}
bucket-region: ${{ secrets.AWS_REGION }}
delete-removed: true
no-cache: true
private: true
files-to-include: '{.*/**,**}'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}