ubient / laravel-vapor-action

Run Laravel Vapor commands directly from Github Actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatically Add Commit SHA and Message

lorenzoaiello opened this issue · comments

Hello,

It would be great if the commit hash and message were automatically included by default.

Ref Docs: https://docs.vapor.build/1.0/projects/deployments.html#git-commit-information

I got the commit information working using this workflow, which is slightly modified from the readme (Docker example). The last line is all I modified, it uses the github variable that's already present when Actions are run.

name: Deploy to Vapor

on:
  push:
    branches: [ master ]

jobs:
  vapor:
    name: Check out and deploy using Vapor
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Login to Github Package Registry
      run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
    - name: Deploy to Production
      run: |
        docker run \
          --env VAPOR_API_TOKEN=${{ secrets.VAPOR_API_TOKEN }} \
          --volume $(pwd):/app \
          docker.pkg.github.com/ubient/laravel-vapor-action/laravel-vapor-action:latest \
          deploy production --commit="${{ github.event.commits[0].id }}" --message="${{ github.event.commits[0].message }}"

Thanks for starting this conversation!

I'm curious; someone else opened a PR earlier that seems to serve the same purpose, but I ended up closing it because I (as well as others) believe that Github already does this automatically, and when mentioning this, the conversation more or less dried up: #13 (comment)

Am I missing something? Thanks!

Hm I'm new to Vapor, but running vapor deploy production on my computer and the simple config file in the readme both produce this kind of deployment:
Screenshot showing a Laravel Vapor deployment that says No Commit Information

Hm, I see.. do you have the repository linked in the Project Settings on Vapor?
(If you go to your project, there is a 'Project Settings' link in the top right):

Screenshot 2020-06-29 at 16 53 13


Edit: Apparently this just has to do with UI-interaction, where Vapor can then give direct links to the Github commit itself, so that shouldn't matter after all.

I do have it linked, but maybe it has something to do with my GitHub repository being private? I never gave Vapor OAuth access to my GitHub account.

Hmm, no, that shouldn't matter I also have no Vapor OAuth access on my Github Account / Organizations.

I do have to admit that the No Commit Information does occur sometimes, but I only had this happen when setting up the repository for Vapor deployments. Ever since then, it's been working just fine:
Screenshot 2020-06-29 at 17 11 04

Anyway, I'll look into it!

Apparently, Vapor automatically grabs the Commit Hash from the currently checked out .git repository (in the CI pipeline) if you don't pass one as an argument:

Since the actions/checkout@v1 ensures Vapor has a checked out version of the repo to run git queries against, it seems to me like everything you have is correct?

What happens when you deploy on merge (like the default config / config above), and trigger the merge (or squash/rebase) via a PR? Does it still not work then? As I mentioned before, I also had the first deployment/commit fail as well, but every deployment after seems to work just fine.

Closing this one due to inactivity. Feel free to re-open it if necessary.