From 1e7d16e03e9b5f7d849a456b841c7be355c49fd4 Mon Sep 17 00:00:00 2001 From: erickvneri Date: Tue, 13 Feb 2024 14:52:09 -0600 Subject: [PATCH] feature: testing cron workflow --- .../cron-develop-invites-acceptances.yaml | 73 +++++++++++++++++++ .../cron-production-invites-acceptances.yaml | 0 README.md | 13 +++- readme_template | 7 ++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cron-develop-invites-acceptances.yaml create mode 100644 .github/workflows/cron-production-invites-acceptances.yaml create mode 100644 readme_template diff --git a/.github/workflows/cron-develop-invites-acceptances.yaml b/.github/workflows/cron-develop-invites-acceptances.yaml new file mode 100644 index 0000000..5176c28 --- /dev/null +++ b/.github/workflows/cron-develop-invites-acceptances.yaml @@ -0,0 +1,73 @@ +name: "Channel Invites Acceptances (develop)" +run-name: "cron to review acceptances (develop)" +on: + push: + branches: + - feature-workflows + #schedule: + #- cron: "0 0 * * 0" + +jobs: + cron: + runs-on: "ubuntu-latest" + env: + CHANNEL: ${{ secrets.ST_CHANNEL_DEVELOP }} + ST_TOKEN: ${{ secrets.ST_PAT }} + steps: + - name: "checkout" + uses: "actions/checkout@v3" + + - name: "setup smartthings cli" + uses: "actions/setup-node@v3" + with: + node-version: "20.9.0" + - run: "npm install --global @smartthings/cli" + + - name: "setup python" + uses: "actions/setup-python@v3" + with: + python-version: 3.11 + + - name: "test step" + run: "git status" + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: "update channel information" + uses: "actions/checkout@v3" + - run: | + CHANNEL_INFO=$(smartthings edge:channels:invites "$CHANNEL" --json --token "$ST_TOKEN"); + NAME=$(echo $CHANNEL_INFO | jq .metadata.name); + OWNER=$(echo $CHANNEL_INFO | jq .metadata.owner); + DESCRIPTION=$(echo $CHANNEL_INFO | jq .metadata.description); + TERMS=$(echo $CHANNEL_INFO | jq .metadata.termsUrl); + ACCEPTANCES=$(echo $CHANNEL_INFO | jq .acceptances); + ACCEPT_URL=$(echo $CHANNEL_INFO | jq .acceptUrl); + + echo $TERMS; + + python -c " + from sys import argv + + template = ''' + - **Name**: {} + - **Owner**: {} + - **Description**: {} + - **Terms URL**: {} + - **Acceptances**: {} + + Accept Invite + + ''' + + template = template.format(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]) + + content = None + with open('readme_template', 'r') as template_doc: + tag = 'channel-info-here' + content = template_doc.read() + content = content.replace(tag, template) + with open('README.md', 'w') as readme: + readme.write(content) + " "$NAME" "$OWNER" "$DESCRIPTION" "$TERMS" "$ACCEPTANCES" "$ACCEPT_URL"; + cat README.md; diff --git a/.github/workflows/cron-production-invites-acceptances.yaml b/.github/workflows/cron-production-invites-acceptances.yaml new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index e3b252b..d79bf36 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # Edge Drivers for Zigbee and LAN devices +### Channel + +- Name: erick +- Owner: lala +- Description: cas +- Terms URL: ca +- Acceptances: dasf + +Accept Invite + + ### Index -- [Zigbee Edge Drivers](./zigbee) +- [Zigbee Edge Drivers](./zigbee) diff --git a/readme_template b/readme_template new file mode 100644 index 0000000..7e1170e --- /dev/null +++ b/readme_template @@ -0,0 +1,7 @@ +# Edge Drivers for Zigbee and LAN devices + +### Channel +channel-info-here +### Index + +- [Zigbee Edge Drivers](./zigbee)