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

Deploying to *** #10

Closed
tribakzero opened this issue Apr 12, 2020 · 2 comments
Closed

Deploying to *** #10

tribakzero opened this issue Apr 12, 2020 · 2 comments

Comments

@tribakzero
Copy link

tribakzero commented Apr 12, 2020

This may be an issue on how I'm doing things, but I'm not able to deploy to my project and the log says I'm trying to push to *** instead.

Here's the full output:

Run AkhileshNS/heroku-deploy@master
Created and wrote to ~./netrc
Successfully logged into heroku
heroku: Press any key to open up the browser to login or q to exit:  ›   Warning: heroku update available from 7.39.1 to 7.39.2.
Added git remote heroku
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

            Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch. 
            (If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml. 
            Specifically, the error was: Error: Command failed: git push heroku :refs/heads/master 
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/***.git
 ! [remote rejected] master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/***.git'

Here's my yml file:

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    # Install dependencies
    - name: Install dependencies
      run: yarn install

    # Tests project
    - name: Test project
      run: yarn test

    # Builds project
    - name: Build project
      run: yarn build

    # Deploys to Heroku
    - name: Deploy to Heroku
      uses: AkhileshNS/heroku-deploy@master
      with:
        # This will be used for authentication. You can find it in your heroku homepage account settings
        heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
        # Email that you use with heroku
        heroku_email: ${{ secrets.HEROKU_EMAIL }}
        # The appname to use for deploying/updating
        heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
        # An optional buildpack to use when creating the heroku application
        buildpack: # optional
        # The branch that you would like to deploy to Heroku
        branch: # optional, default is HEAD
        # Set this to true if you don't want to use --force when switching branches
        dontuseforce: # optional
        # Will deploy using Dockerfile in project root.
        usedocker: # optional
        # Set if your app is located in a subdirectory.
        appdir: # optional, default is   

I added the secrets to my config a couple times already to make sure I wrote the correct values, seems like at least API_KEY is working correctly because the action is able to login.

I don't know what else to try, I tried adding the app name to the yml or adding it as a secret to no avail.
I'm learning Github Actions and I'm frustrated because I can't find a way out of this fairly easy problem.

Do you have an idea on how could I fix this?

@AkhileshNS
Copy link
Owner

I would get rid of the "buildpack", "branch", "dontuseforce" and "appdir" variables in your action since you aren't using them.

Your yaml file should look something like:

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Install dependencies
      run: yarn install

    - name: Test project
      run: yarn test

    - name: Build project
      run: yarn build

    - name: Deploy to Heroku
      uses: AkhileshNS/heroku-deploy@master
      with:
        heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
        heroku_email: ${{ secrets.HEROKU_EMAIL }}
        heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}

Also in your output *** is just github actions hiding secrets from being printed in the logs. So its likely the *** is actually just the value of secrets.HEROKU_APP_NAME.

Also never leave a value like appdir: in yaml. Always assign it some value like appbir: "./dist" or leave it out. Because otherwise, the value can't get initialized with its default value

@tribakzero
Copy link
Author

Thank you for the prompt response, you're great, it was that. Also thanks for helping me understand the *** thing.

I'll keep the rest of your advice in mind, have a great day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants