Parallel #2934
Workflow file for this run
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: 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@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
- 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:2023.8.4@sha256:5970dce5dab73ec4c70be107b799b59e9f47027ac6ec0215d34cf89f664fed9c | |
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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.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 }}' | |
}); | |