From b4e44fa2b12f17101b6dfea0295491ca2bc77d18 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Fernadez Date: Tue, 16 Apr 2024 15:09:04 -0600 Subject: [PATCH] Clone wp post --- .github/actions/clone-post.yml | 37 ----------------------- .github/actions/upload_to_s3.yml | 29 ------------------ .github/workflows/clone_post_job.yml | 41 ++++++++++++++++++++++++++ .github/workflows/upload_to_s3_job.yml | 21 +++++++++++++ .github/workflows/workflow_call_qa.yml | 34 ++++++++++----------- 5 files changed, 77 insertions(+), 85 deletions(-) delete mode 100644 .github/actions/clone-post.yml delete mode 100644 .github/actions/upload_to_s3.yml create mode 100644 .github/workflows/clone_post_job.yml create mode 100644 .github/workflows/upload_to_s3_job.yml diff --git a/.github/actions/clone-post.yml b/.github/actions/clone-post.yml deleted file mode 100644 index 38f22b8..0000000 --- a/.github/actions/clone-post.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Clone Post -description: Clone WordPress post -inputs: - environment: - description: 'The deployment environment (QA, SBOX, PROD)' - required: true - postID: - description: 'The ID of the post to clone' - required: true -runs: - using: 'composite' - 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 requests - - name: Run cloning script - run: | - python wordpress-cloning-script.py ${{ inputs.environment }} ${{ inputs.postID }} ${{ inputs.WORDPRESS_USERNAME }} ${{ inputs.WORDPRESS_PASSWORD }} - - name: Configure git user - run: | - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - - name: Commit and push changes - run: | - git add . - if git diff --staged --quiet; then - echo "No changes to commit." - else - git commit -m "Cloned WordPress post ${{ inputs.postID }} for environment ${{ inputs.environment }}" - git push diff --git a/.github/actions/upload_to_s3.yml b/.github/actions/upload_to_s3.yml deleted file mode 100644 index 4281302..0000000 --- a/.github/actions/upload_to_s3.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Clone Post -description: Clone WordPress post -inputs: - environment: - description: 'The deployment environment (QA, SBOX, PROD)' - required: true - postID: - description: 'The ID of the post to clone' - required: true - WORDPRESS_USERNAME: - description: 'WordPress Username' - required: true - WORDPRESS_PASSWORD: - description: 'WordPress Password' - required: true -runs: - using: 'composite' - steps: - - - name: Upload HTML to S3 - uses: jakejarvis/s3-sync-action@master - with: - args: --follow-symlinks --delete - env: - AWS_S3_BUCKET: orcid-qa-public-page - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: 'us-east-1' # Adjust to your AWS region - SOURCE_DIR: 'dist' \ No newline at end of file diff --git a/.github/workflows/clone_post_job.yml b/.github/workflows/clone_post_job.yml new file mode 100644 index 0000000..231098c --- /dev/null +++ b/.github/workflows/clone_post_job.yml @@ -0,0 +1,41 @@ +name: "Clone WordPress Post Job" +description: "Clones a WordPress post and commits changes to the repository" + +on: + workflow_call: + inputs: + environment: + required: true + type: string + postID: + required: true + type: string + +jobs: + clone_post: + runs-on: ubuntu-latest + 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 requests + - name: Run cloning script + run: python wordpress-cloning-script.py ${{ inputs.environment }} ${{ inputs.postID }} + - name: Configure git user + run: | + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + - name: Commit and push changes + run: | + git add . + if git diff --staged --quiet; then + echo "No changes to commit." + else + git commit -m "Cloned WordPress post ${{ inputs.postID }} for environment ${{ inputs.environment }}" + git push \ No newline at end of file diff --git a/.github/workflows/upload_to_s3_job.yml b/.github/workflows/upload_to_s3_job.yml new file mode 100644 index 0000000..2c8f7ca --- /dev/null +++ b/.github/workflows/upload_to_s3_job.yml @@ -0,0 +1,21 @@ +name: "Upload to S3 Job" +description: "Uploads HTML files to AWS S3 bucket" + +on: + workflow_call: + jobs: + upload_to_s3: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Upload HTML to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: orcid-qa-public-page + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: 'us-east-1' + SOURCE_DIR: 'dist' \ No newline at end of file diff --git a/.github/workflows/workflow_call_qa.yml b/.github/workflows/workflow_call_qa.yml index c5a79ad..bb8851c 100644 --- a/.github/workflows/workflow_call_qa.yml +++ b/.github/workflows/workflow_call_qa.yml @@ -1,30 +1,26 @@ -name: Clone Wordpress QA +name: Clone and Upload WordPress Post on: workflow_dispatch: inputs: + environment: + required: true + type: string + description: "The deployment environment (QA, SBOX, PROD)" + default: "PROD" postID: required: true type: string description: "The ID of the post to clone" - default: "24531" + default: "27964" + jobs: clone_post: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Clone Post - uses: .github/actions/clone-post.yml - with: - environment: QA - postID: ${{ github.event.inputs.postID }} - upload_to_s3: - runs-on: ubuntu-latest - needs: [clone_post] - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Clone Post - uses: .github/actions/upload_to_s3.yml + uses: ./.github/workflows/clone_post_job.yml + with: + environment: ${{ github.event.inputs.environment }} + postID: ${{ github.event.inputs.postID }} + upload_to_s3: + needs: clone_post + uses: ./.github/workflows/upload_to_s3_job.yml \ No newline at end of file