static/refs/remotes/main~tuanngocptn #15
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: vtd fe static | |
on: | |
repository_dispatch: | |
types: | |
- static/** | |
env: | |
TRIGGERING_ACTOR: ${{ github.event.client_payload.triggering_actor}} | |
TRIGGERING_REF: ${{ github.event.client_payload.triggering_ref}} | |
jobs: | |
setup-build-publish-deploy: | |
environment: ${{ github.event.client_payload.triggering_env }} | |
name: Setup build publish deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ secrets.STATIC_WEB_REPOSITORY }} | |
token: ${{ secrets.GH_PAT }} | |
ref: ${{ env.TRIGGERING_REF }} | |
path: source | |
- name: Checkout target | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ secrets.FE_PPAP_REPOSITORY }} | |
ref: gh-pages | |
path: target | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Running | |
run: | | |
rm -rf target/${{ env.TRIGGERING_REF }} | |
mkdir target/${{ env.TRIGGERING_REF }} | |
rm -rf source/.git | |
mv source/* target/${{ env.TRIGGERING_REF }}/ | |
- name: Push | |
working-directory: target | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
{ | |
git add -A && | |
git commit -m "deploy: ${{ env.TRIGGERING_REF }}" && | |
git push origin gh-pages | |
} || { | |
exit 0 | |
} | |
- name: Authen GCP | |
if: ${{ env.TRIGGERING_REF == 'main' }} | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' | |
- name: Setup GCP | |
if: ${{ env.TRIGGERING_REF == 'main' }} | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Upload to GCP Storage | |
if: ${{ env.TRIGGERING_REF == 'main' }} | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: target/main | |
destination: ${{ secrets.BUCKET_NAME }} | |
parent: false |