Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow map try 2 #1866

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/generate-workflow-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build, push to AWS ECR, and deploy

on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/**"


jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# Generate a bot token that will be used for all workflow actions.
# This is required as the default repo GITHUB_TOKEN does not trigger new workflow runs.
- name: Obtain a Notify PR Bot GitHub App Installation Access Token
run: |
TOKEN="$(npx obtain-github-app-installation-access-token@1.1.0 ci ${{ secrets.GH_APP_CREDENTIALS_TOKEN }})"
echo "::add-mask::$TOKEN"
echo "GITHUB_TOKEN=$TOKEN" >> $GITHUB_ENV

# generate .md file
- uses: KhudaDad414/workflows2md-action@v0.1.1
id: workflows2md

- name: setup git config
run: |
git config user.name "Workflow Update"
git config user.email "action@github.com"

- name: Branch protection OFF
uses: octokit/request-action@v2.x
with:
route: PUT /repos/:repository/branches/main/protection
repository: ${{ github.repository }}
required_status_checks: |
null
required_linear_history: |
null
enforce_admins: |
null
required_pull_request_reviews: |
null
restrictions: |
null
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

- name: commit
env:
NEW_VERSION: ${{ steps.tag_version.outputs.new_tag }}
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
run: |
git add ${{ steps.workflows2md.outputs.path }}
git commit -m "Updating workflows map file"
git push origin main

- name: Branch protection ON
if: always()
uses: octokit/request-action@v2.x
with:
route: PUT /repos/:repository/branches/main/protection
repository: ${{ github.repository }}
required_status_checks: |
strict: true
checks:
- context: testing_manifest
required_linear_history: |
true
enforce_admins: |
true
required_pull_request_reviews: |
required_approving_review_count: 1
restrictions: |
null
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

# - name: Notify Slack channel if this job failed
# if: ${{ failure() }}
# run: |
# json="{'text':'<!here> CI is failing in <https://github.com/cds-snc/notification-admin/|notification-admin> !'}"
# curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK }}
Loading