Added the PIR sensor to GPIO19 #19
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: ESP Environment Sensor | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Arduino CLI | |
uses: arduino/setup-arduino-cli@v2 | |
- name: Install platform | |
run: | | |
arduino-cli config init | |
arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json | |
arduino-cli core update-index | |
arduino-cli core install esp32:esp32 | |
- name: Install Arduino Libraries | |
run: | | |
arduino-cli lib install "ArduinoJson" | |
arduino-cli lib install "Adafruit GFX Library" | |
arduino-cli lib install "Adafruit ST7735 and ST7789 Library" | |
# - name: Compile | |
# uses: arduino/compile-sketches@v1 | |
# with: | |
# fqbn: "esp32:esp32:lolin32" | |
# sketch-paths: | | |
# - ./arduino_projects/esp-environment-sensor/esp-environment-sensor | |
# verbose: true | |
# libraries: | | |
# - name: "ArduinoJson" | |
# - name: "Adafruit GFX Library" | |
# - name: "Adafruit ST7735 and ST7789 Library" | |
- name: Compile Sketch | |
run: | | |
arduino-cli compile --fqbn esp32:esp32:lolin32 --verbose --output-dir output ./arduino_projects/esp-environment-sensor/esp-environment-sensor | |
echo "Compiled firmware location:" | |
find ./arduino_projects/esp-environment-sensor/ -type f | |
find ./ -type f -name "esp-environment-sensor.ino.merged.bin" 2>/dev/null | |
ls output | |
- name: Upload firmware artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: firmware | |
path: ./output/esp-environment-sensor.ino.merged.bin | |
retention-days: 1 | |
upload: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download firmware artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: firmware | |
path: ./output | |
- name: Generate IoT Job Document | |
run: | | |
FIRMWARE_URL="https://${{ secrets.OTA_S3_BUCKET }}.s3.${{ secrets.AWS_REGION }}.amazonaws.com/esp-environment-sensor/esp-environment-sensor.ino.merged.bin" | |
FIRMWARE_HASH=$(sha256sum ./output/esp-environment-sensor.ino.merged.bin | awk '{print $1}') | |
cat <<EOF > ./output/ota-job-document.json | |
{ | |
"operation": "otaUpdate", | |
"firmware": { | |
"url": "${FIRMWARE_URL}", | |
"version": "1.0.0", | |
"hash": "${FIRMWARE_HASH}" | |
}, | |
"actions": { | |
"validate": true, | |
"applyImmediately": true, | |
"rollbackOnFailure": true | |
} | |
} | |
EOF | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.ROLE_NAME }} | |
role-session-name: "github-actions-session" | |
mask-aws-account-id: true | |
- name: Upload Firmware | |
run: | | |
aws s3 cp ./output/esp-environment-sensor.ino.merged.bin s3://${{ secrets.OTA_S3_BUCKET }}/esp-environment-sensor/esp-environment-sensor.ino.merged.bin | |
aws s3 cp ./output/ota-job-document.json s3://${{ secrets.OTA_S3_BUCKET }}/esp-environment-sensor/ota-job-document.json | |
- name: Create AWS IoT Job | |
run: | | |
JOB_ID="esp32-ota-job-${{ github.run_number }}" | |
aws iot create-job \ | |
--job-id $JOB_ID \ | |
--targets "arn:aws:iot:${{ secrets.AWS_REGION }}:${{ secrets.AWS_ACCOUNT_ID }}:thinggroup/${{ secrets.THING_GROUP_NAME }}" \ | |
--document-source "s3://${{ secrets.OTA_S3_BUCKET }}/esp-environment-sensor/ota-job-document.json" \ | |
--job-executions-rollout-config '{"maximumPerMinute":5}' \ | |
--abort-config '{"criteriaList":[{"failureType":"FAILED","action":"CANCEL","thresholdPercentage":50.0,"minNumberOfExecutedThings":1}]}' |