🤖 auto update production ⬆️ #693
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: Minify Assets Files(css/js) and Deploy to Stage | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
minify-css-and-js: | |
name: Minify CSS and JS files | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Actions | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.head_ref}} | |
persist-credentials: false | |
- name: Checkout Actions (main) | |
if: github.ref == 'refs/heads/main' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.ref}} | |
persist-credentials: false | |
- name: Auco Minify JS | |
uses: nizarmah/auto-minify@master | |
with: | |
directory: "themes/vald/static/js" | |
- name: Auco Minify CSS | |
uses: nizarmah/auto-minify@master | |
with: | |
directory: "themes/vald/static/css" | |
- name: Check Changes | |
id: git_diff_static | |
run: | | |
diff=`git diff themes/vald/static/` | |
if [ ! -z "$diff" ] ; then \ | |
echo "diff=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit Minified Files (pull_request) | |
if: steps.git_diff_static.outputs.diff == 'true' && github.event_name== 'pull_request' | |
run: | | |
git config --global user.name "vdaas-ci" | |
git config --global user.email "ci@vdaas.org" | |
git add themes/vald/static | |
git commit --signoff -m ":robot: auto update minified files :recycle:" | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git push origin ${{ github.head_ref }} | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
- name: Commit Minified Files (main) | |
if: steps.git_diff_static.outputs.diff == 'true' && github.ref == 'refs/heads/main' | |
run: | | |
git config --global user.name "vdaas-ci" | |
git config --global user.email "ci@vdaas.org" | |
git checkout main | |
git add themes/vald/static | |
git commit --signoff -m ":robot: auto update minified files :recycle:" | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git push origin main | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
deploy-stage: | |
name: Deploy to Stage Env | |
runs-on: ubuntu-latest | |
needs: | |
- minify-css-and-js | |
steps: | |
- name: Checkout Actions | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.head_ref}} | |
persist-credentials: false | |
- name: Checkout Actions (main) | |
if: github.ref == 'refs/heads/main' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.ref}} | |
persist-credentials: false | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: latest | |
- name: Setup for Build | |
if: github.event_name == 'pull_request' | |
run: | | |
git config --global user.name "vdaas-ci" | |
git config --global user.email "ci@vdaas.org" | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git pull origin ${{ github.head_ref }} | |
git submodule update --init --recursive | |
cd preview | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git checkout gh-pages | |
git pull origin gh-pages | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
- name: Setup for Build (main) | |
if: github.ref == 'refs/heads/main' | |
run: | | |
git config --global user.name "vdaas-ci" | |
git config --global user.email "ci@vdaas.org" | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git pull origin main | |
git submodule update --init --recursive | |
cd preview | |
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git checkout gh-pages | |
git pull origin gh-pages | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
- name: Stage Build | |
run: | | |
make build/stage | |
- name: Check Changes preview | |
id: git_diff_preview | |
run: | | |
diff=`git diff preview/` | |
if [ ! -z "$diff" ] ; then \ | |
echo "diff=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Stage Deploy | |
if: steps.git_diff_preview.outputs.diff == 'true' | |
run: | | |
export LATEST_VERSION=$(make version/latest) | |
cd preview | |
git checkout gh-pages | |
git add . | |
git commit --signoff -m ":arrow_up: v${LATEST_VERSION} `date`" | |
git push origin gh-pages | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
- name: Commit Stage Changes | |
if: steps.git_diff_preview.outputs.diff == 'true' && github.event_name == 'pull_request' | |
run: | | |
git add preview | |
git commit --signoff -m ":robot: auto update stage :arrow_up:" | |
git push origin ${{ github.head_ref }} | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
- name: Commit Stage Changes (main) | |
if: steps.git_diff_preview.outputs.diff == 'true' && github.ref == 'refs/heads/main' | |
run: | | |
git add preview | |
git commit --signoff -m ":robot: auto update stage :arrow_up:" | |
git push origin main | |
env: | |
GITHUB_USER: ${{ secrets.DISPATCH_USER }} | |
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} |