Skip to content

Commit

Permalink
Clone wp post
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Mendoza Fernadez authored and Leonardo Mendoza Fernadez committed Apr 16, 2024
1 parent f7fbbf4 commit b4e44fa
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 85 deletions.
37 changes: 0 additions & 37 deletions .github/actions/clone-post.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/actions/upload_to_s3.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/clone_post_job.yml
Original file line number Diff line number Diff line change
@@ -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 '[email protected]'
- 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
21 changes: 21 additions & 0 deletions .github/workflows/upload_to_s3_job.yml
Original file line number Diff line number Diff line change
@@ -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'
34 changes: 15 additions & 19 deletions .github/workflows/workflow_call_qa.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b4e44fa

Please sign in to comment.