Run twice automatically and tag is not working

Hi all,

I met 3 problems when I trying to build with 2.0, I already try all night and can’t find the reason, kindly help me to solve them.

The problems are:

  1. CircleCI run twice with the same commit in workflow.
  2. Tag is not working. I expect it deploy if and only if with prefix newpost tag, but it deploy everytime.
  3. It’s seems the directory that generate in previous job doesn’t be save, my deploy goes failed because can’t find the directory that generate in job build.

Not sure if you could see my page: https://circleci.com/gh/jimmylin212

My config is below:

version: 2
jobs:
  build:
    docker:
      - image: felicianotech/docker-hugo:0.30.2
    working_directory: ~/project
    steps:
      - checkout
      - run:
          name: "Run Hugo"
          command: |
            git submodule sync && git submodule update --init 
            git submodule foreach --recursive git pull origin master
            HUGO_ENV=production hugo -v

  deploy:
    docker:
      - image: felicianotech/docker-hugo:0.30.2
    working_directory: ~/project
    steps:
      - add_ssh_keys:
          fingerprints:
            - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      - run:
          name: "Deploy to github.io"       
          command: |
            ## Do I need to check everything again like in job build?
            cd ~/project/public
            git config --global user.email "jimmylin212@gmail.com"
            git config --global user.name "Jimmy Lin"
            git add -A
            git commit -m "Deploy from CircleCI"
            git push origin HEAD:master

workflows:
  version: 2
  build-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            tags:
              only: /^newpost-.*/

Thank you very much.

CircleCI run twice with the same commit in workflow.

This usually indicates that there are multiple GitHub hooks. Can you double check on the GitHub side to make sure?

Tag is not working. I expect it deploy if and only if with prefix newpost tag, but it deploy everytime.

You need to add filters on every step in your workflow. This is described here.

See this project for a working example.

It’s seems the directory that generate in previous job doesn’t be save, my deploy goes failed because can’t find the directory that generate in job build.

I am not sure what you are saying here. Could you clarify please?

1 Like

Thank you, I check my Github and found there are 2 hook.

1 Like