Skip to content

Rotate garden cams #3669

Rotate garden cams

Rotate garden cams #3669

Workflow file for this run

name: cd
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
concurrency:
group: cd-${{ github.event.pull_request.number }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
# debug:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # tag=v6.1.0
# env:
# CURRENT_REF: ${{ github.event.pull_request.head.ref }}
# ENVIRONMENT: production
# with:
# script: |
# var deployments = await github.rest.repos.listDeployments({
# ...context.repo,
# environment: process.env.ENVIRONMENT,
# })
# for (const deployment of deployments.data) {
# if (deployment.ref == process.env.CURRENT_REF) {
# console.log(`deployment ${deployment.id} is for the current ref`);
# continue;
# }
# console.log(`querying status of deployment ${deployment.id}`);
# var statuses = await github.rest.repos.listDeploymentStatuses({
# ...context.repo,
# deployment_id: deployment.id,
# })
# for (const status of statuses.data) {
# console.log(`deployment ${deployment.id} status ${status.state}`);
# if (status.state == 'success' || status.state == 'in_progress' || status.state == 'pending' || status.state == 'queued') {
# var pulls = await github.rest.pulls.list({
# ...context.repo,
# ref: context.repo.owner + ':' + deployment.ref,
# state: 'open'
# });
# if (pulls.data.length > 0) {
# console.log(`deployment ${deployment.id} has open pull requests`);
# break;
# }
# } else {
# console.log("skipping")
# continue;
# }
# }
# }
validate-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Generate fake SSL cert
run: |
openssl req -x509 -newkey rsa:1024 -subj '/CN=example.com' -nodes -keyout key.pem -out cert.pem
- name: Test config
uses: docker://homeassistant/home-assistant:2024.4.4@sha256:73b70d36610466a46f1ae3b890bc43f06b48a1ac98b4f28c5d52cf424e476cd5
with:
entrypoint: ./script/cibuild
script-deploy:
runs-on: ubuntu-latest
needs: validate-config
if: |
( github.event.action == 'labeled' && github.event.label.name == 'deploy') ||
( github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'deploy') )
environment: production
concurrency: production
steps:
- name: deploy
run: 'true'
create-deploy-status:
runs-on: ubuntu-latest
needs: script-deploy
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
await github.rest.repos.createCommitStatus({
...context.repo,
sha: context.payload.pull_request.head.sha,
state: 'success',
context: 'deploy',
description: 'PR was deployed with GitHub Actions',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
});