Skip to content

Commit

Permalink
Create deployment_automation.yml
Browse files Browse the repository at this point in the history
This configuration:

- Utilizes repository_dispatch for flexibility.
- Ensures secure handling of secrets.
- Provides notifications and logging for audit purposes.
- Could potentially integrate scanning of the repository for issues as a cron job within GitHub Actions, if periodic scanning is needed.
  • Loading branch information
cywf committed May 8, 2024
1 parent 5da7776 commit ab605d7
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deployment_automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deployment Automation

on:
issues:
types: [opened, labeled]
repository_dispatch:
types: [deploy_trigger]

jobs:
deploy:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'deployment') || github.event.action == 'deploy_trigger'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Git user
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
- name: Create Branch
id: create_branch
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: |
BRANCH_NAME="deploy-${{ github.event.issue.number }}"
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME
echo "::set-output name=BRANCH_NAME::$BRANCH_NAME"
- name: Create Project Board
uses: alex-page/github-project-automation-plus@v0.8.1
with:
project: 'Deployment Project'
column: 'To do'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Fork Repository
run: |
curl \
-X POST \
-H "Authorization: token ${{ secrets.DEPLOY_TOKEN }}" \
-d '{"organization": "new-org", "repo": "${{ github.repository }}"}' \
"https://api.github.com/repos/${{ github.repository }}/forks"
- name: Notify Completion
if: success()
uses: actions/github-script@v5
with:
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Deployment workflow completed successfully.'
})
- name: Log Action
run: |
echo "Deployment process for issue ${{ github.event.issue.number }} completed" >> deployment_log.txt

0 comments on commit ab605d7

Please sign in to comment.