0
votes

This is the first workflow I'm writing with Github Actions, I am using this worfklow combined with AWS CodeDeploy to automate deployment.

# .github/workflows/deployment.yml

on:
    push:
        branches:
            - Production

jobs:
    deploy:
        runs-on: ubuntu-latest
        steps:
            -   uses: aws-actions/configure-aws-credentials@v1
                with:
                    aws-access-key-id: //AWS_ACCESS_KEY_ID
                    aws-secret-access-key: //AWS_SECRET_KEY
                    aws-region: // region
            -   uses: actions/checkout@v2
            -   id: deploy
                uses: webfactory/[email protected]
            -   uses: peter-evans/commit-comment@v1
                with:
                    token: ${{ secrets.GITHUB_TOKEN }}
                    body: |
                        @${{ github.actor }} this was deployed as [${{ steps.deploy.outputs.deploymentId }}](https://console.aws.amazon.com/codesuite/codedeploy/deployments/${{ steps.deploy.outputs.deploymentId }}?region=eu-central-1) to group `${{ steps.deploy.outputs.deploymentGroupName }}`.

Everything is working perfectly when I push new commits to the branch "Production" but the problem is that with every new pull request to merge feature branches into the "dev" branch , Github runs checks on the pull requests and executes the workflow, which is not needed or written in its code.

1
You can add on the branches list a - '!dev' to prevent the workflow to trigger on this specific branch. There is a branches-ignore option as well (reference: docs.github.com/en/actions/reference/…) - GuiFalourd
Thank you this is very helpful - joe1531

1 Answers

0
votes

I found the cause. In previous commmits, I had the worfklow written with the event on pull request and feature branches that are still not up to date with the workflow.yml still use the old version which has the "on pull request event trigger".