Merge pull request #60 from openjournalteam/53-permission #90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SyncToS3-IDrive | |
# Controls when the action will run. | |
on: | |
push: | |
branches: | |
- 33 | |
- 32 | |
- 31 | |
- "update-action-2" | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# https://github.com/marketplace/actions/s3-sync | |
steps: | |
- uses: actions/checkout@master | |
- name: Retrieve JSON File | |
id: json_properties | |
uses: zoexx/github-action-json-file-properties@release | |
with: | |
file_path: "./.github/package.json" | |
- name: Retrieve S3 JSON File | |
id: s3_key | |
uses: zoexx/github-action-json-file-properties@release | |
with: | |
file_path: "./.github/s3.json" | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-name@v6 | |
- name: Set all variable used | |
run: | | |
echo "UPLOAD_FOLDER=${{steps.json_properties.outputs.platform}}/${{steps.json_properties.outputs.product_category}}/${{steps.json_properties.outputs.name}}/${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV | |
echo "REPO_NAME=${{steps.json_properties.outputs.name}}" >> $GITHUB_ENV | |
- name: Create folder and removing .git and .github dir | |
run: | | |
mkdir ./ojtPlugin | |
mkdir ./zipped | |
rsync -a ./ ./ojtPlugin/$REPO_NAME | |
rm -rf ./ojtPlugin/$REPO_NAME/.git* | |
rm -rf ./ojtPlugin/$REPO_NAME/ojtPlugin | |
- name: Compress Tar | |
uses: a7ul/[email protected] | |
with: | |
command: c | |
cwd: ./ojtPlugin | |
files: ./ojtPlugin | |
outPath: ./zipped/${{steps.json_properties.outputs.name}}.tar.gz | |
- name: Zip the repo and Pack to S3_Upload folder before uploading | |
uses: vimtor/action-zip@v1 | |
with: | |
files: ./ojtPlugin | |
dest: ./zipped/${{steps.json_properties.outputs.name}}.zip | |
# Copy the version.xml file to the zipped folder | |
- name: Copy the version.xml file | |
run: | | |
cp ./ojtPlugin/ojtPlugin/version.xml ./zipped/version.xml | |
#everthing is working now, then upload | |
- name: Upload Zip File to S3 Folder ( Version ) | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks --delete --include '*' --exclude './.git/*' --exclude './.github/*' --exclude './.vscode/*' --exclude '.gitignore' --exclude './ojtPlugin/*' --exclude './.gitmodules' | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ steps.s3_key.outputs.region }} | |
AWS_S3_ENDPOINT: ${{ steps.s3_key.outputs.endpoint }} | |
AWS_S3_BUCKET: ${{ steps.s3_key.outputs.bucket }} | |
SOURCE_DIR: "./zipped/" | |
DEST_DIR: "/$UPLOAD_FOLDER/" |