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 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):
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:
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:
- https://github.com/laravel/vapor-cli/blob/dda6b1ab8c98008a470d0bb73e1c759be8d1ecb6/src/Commands/DeployCommand.php#L153
- https://github.com/laravel/vapor-cli/blob/bfd7680dd470d95019bdb60af32fb2d0ef6ff86c/src/Git.php#L14
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.