Allow meteo hourly data matches from +-1h #129
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: render | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read .node-version | |
run: echo ::set-output name=version::$(cat .node-version) | |
id: node-version | |
- uses: actions/[email protected] | |
with: | |
node-version: ${{steps.node-version.outputs.version}} | |
- run: npm install | |
- run: npm test | |
build: | |
name: Build | |
needs: test | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: render | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
GCP_REGION: europe-west3 | |
GCP_PROJECT: weather-display-367406 | |
GCP_BUCKET: weather-display-deployment | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
version: '408.0.0' | |
- name: Read .node-version | |
run: echo ::set-output name=version::$(cat .node-version) | |
id: node-version | |
- uses: actions/[email protected] | |
with: | |
node-version: ${{steps.node-version.outputs.version}} | |
- run: npm install | |
- run: npm run build | |
- name: Get current timestamp | |
id: timestamp | |
run: echo "::set-output name=timestamp::$(date +'%s')" | |
- name: Upload deployable zip | |
env: | |
FILE_NAME: weather-display-${{ steps.timestamp.outputs.timestamp }}-${{ env.GITHUB_SHA }}.zip | |
run: | | |
cd dist/ | |
zip -r ../$FILE_NAME . | |
cd .. | |
gcloud storage cp $FILE_NAME gs://$GCP_BUCKET | |
outputs: | |
file-name: weather-display-${{ steps.timestamp.outputs.timestamp }}-${{ env.GITHUB_SHA }}.zip | |
deploy: | |
name: Deploy | |
needs: ["build"] | |
runs-on: ubuntu-latest | |
concurrency: cloud-function-deploy | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
FILE_URL: gs://weather-display-deployment/${{ needs.build.outputs.file-name }} | |
GCP_REGION: europe-west3 | |
GCP_PROJECT: weather-display-367406 | |
steps: | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
version: '408.0.0' | |
# https://cloud.google.com/sdk/gcloud/reference/functions/deploy | |
- run: gcloud functions deploy weather-display --entry-point render --source=$FILE_URL --region $GCP_REGION --project $GCP_PROJECT | |
- name: 'Test rendering' | |
env: | |
WEATHER_DISPLAY_API_KEY: ${{ secrets.WEATHER_DISPLAY_API_KEY }} | |
run: curl --fail "$(gcloud functions describe weather-display --region $GCP_REGION --project $GCP_PROJECT --format=json | jq -r .httpsTrigger.url)?lat=60.222&lon=24.83&locationName=Espoo&batteryLevel=100&timezone=Europe/Helsinki&apiKey=$WEATHER_DISPLAY_API_KEY" |