Merge pull request #626 from NASA-IMPACT/dev #291
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: CI/CD | |
on: | |
- push | |
jobs: | |
run-linters: | |
name: Run linters | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11.8 | |
cache: pip | |
- name: Install Python dependencies | |
run: pip install black flake8 | |
- name: Run linters | |
uses: wearerequired/lint-action@v1 | |
with: | |
black: true | |
flake8: true | |
flake8_args: "--ignore E1,E2,E3,E5,W1,W2,W3,W5" # black already handles formatting, this prevents conflicts | |
deploy-to-staging: | |
needs: run-linters | |
if: github.ref_name == 'dev' | |
concurrency: staging | |
uses: "./.github/workflows/deploy.yml" | |
with: | |
environment: dev | |
secrets: inherit # pass all secrets | |
deploy-to-production: | |
needs: run-linters | |
if: github.ref_name == 'prod' | |
concurrency: production | |
uses: "./.github/workflows/deploy.yml" | |
with: | |
environment: prod | |
secrets: inherit # pass all secrets | |
notify-slack-staging: | |
needs: deploy-to-staging | |
runs-on: ubuntu-latest | |
if: ${{ success() }} | |
steps: | |
- name: Get first line of commit message | |
id: commit-msg | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: echo "::set-output name=first-line::${COMMIT_MSG%%$'\n*'}" | |
notify-slack-production: | |
needs: deploy-to-production | |
runs-on: ubuntu-latest | |
if: ${{ success() }} | |
steps: | |
- name: Get first line of commit message | |
id: commit-msg | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: echo "::set-output name=first-line::${COMMIT_MSG%%$'\n*'}" | |
- name: Post to a Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: "admg" | |
payload: '{"text":"Successfully deployed MI to Production! <https://admg.nasa-impact.net/|Click here> to take a look!"}' | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |