Merge pull request #273 from ymaheshwari1/feat/release-label-workflow #7
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
on: | ||
workflow_call: | ||
inputs: | ||
config-path: | ||
required: true | ||
type: string | ||
secrets: | ||
envPAT: | ||
required: true | ||
HOTWAX_PUBLIC_SECRET: | ||
required: true | ||
VUE_APP_FIREBASE_CONFIG: | ||
required: false | ||
VUE_APP_FIREBASE_VAPID_KEY: | ||
required: false | ||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
environment: development | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Checkout to latest release tag | ||
run: | | ||
git checkout $(git describe --tags `git rev-list --tags --max-count=1`) | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Generate .env file | ||
run: cp .env.example .env | ||
- name: Set Firebase and VAPID Config | ||
run: | | ||
if [[ -n "$VUE_APP_FIREBASE_CONFIG" ]]; then | ||
sed -i "s|VUE_APP_FIREBASE_CONFIG=.*|VUE_APP_FIREBASE_CONFIG=$VUE_APP_FIREBASE_CONFIG|g" .env | ||
sed -i "s|VUE_APP_FIREBASE_VAPID_KEY=.*|VUE_APP_FIREBASE_VAPID_KEY='$VUE_APP_FIREBASE_VAPID_KEY'|g" .env | ||
sed -i "s|const firebaseConfig =.*|const firebaseConfig = $VUE_APP_FIREBASE_CONFIG|g" public/firebase-messaging-sw.js | ||
fi | ||
env: | ||
VUE_APP_FIREBASE_CONFIG: ${{ secrets.VUE_APP_FIREBASE_CONFIG }} | ||
VUE_APP_FIREBASE_VAPID_KEY: ${{ secrets.VUE_APP_FIREBASE_VAPID_KEY }} | ||
- name: Build | ||
run: npm run build | ||
- name: Install Firebase | ||
run: npm install -g firebase-tools | ||
- name: Set Firebase project | ||
run: firebase use default --token "$HOTWAX_PUBLIC_SECRET" | ||
env: | ||
HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} | ||
- name: Deploy | ||
run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:uat | ||
env: | ||
HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: "Fetch release tag" | ||
run: | | ||
echo "LABEL=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV | ||
- name: "Create label" | ||
run: gh label create "release-${{ env.LABEL }}" --color FF7F7E |