Skip to content

Commit

Permalink
refresh token in cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyos committed Aug 7, 2023
1 parent 6d75b35 commit 1aedfef
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions .github/workflows/zalo-mini-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Zalo Mini App
run-name: ${{ github.event_name == 'schedule' && '✨ Refresh token' || '🚀 Deploy' }}

concurrency: zalo-mini-app

on:
push:
branches: ["main"]
branches:
- main
- "feat/**"
pull_request:
branches: ["main"]
branches:
- main
- "feat/**"
schedule:
- cron: "0 0 * * *"

jobs:
deploy:
refresh_token:
if: ${{ github.event_name == 'schedule' }}
runs-on: ubuntu-latest

strategy:
matrix:
mini-app-id: ["194839900003483517"]

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
Expand All @@ -25,14 +31,40 @@ jobs:
node-version: 18.x
cache: "npm"
- run: npx zmp-developer-token login ${{ secrets.ZALO_APP_ID }} ${{ secrets.ZALO_APP_SECRET }} ${{ secrets.ZALO_REFRESH_TOKEN }} >> $GITHUB_ENV
- uses: hmanzur/[email protected]
with:
name: "ZALO_ACCESS_TOKEN"
value: ${{ env.NEW_ACCESS_TOKEN }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- uses: hmanzur/[email protected]
with:
name: "ZALO_REFRESH_TOKEN"
value: ${{ env.NEW_REFRESH_TOKEN }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Report
run: |
echo "### Token renewal success! :sparkles:" >> $GITHUB_STEP_SUMMARY
deploy:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
runs-on: ubuntu-latest

strategy:
matrix:
mini-app-id: ["194839900003483517"]

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- run: npm install
- run: npm install -g zmp-cli
- run: npx zmp-developer-token deploy ${{ matrix.mini-app-id }}
env:
NEW_ACCESS_TOKEN: ${{ secrets.ZALO_ACCESS_TOKEN }}
- name: Report
run: |
echo "### Deployment success! :rocket:" >> $GITHUB_STEP_SUMMARY
Expand Down

0 comments on commit 1aedfef

Please sign in to comment.