├── .github └── workflows │ └── docker-publish.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE.md ├── README.md ├── action.yml ├── images └── project-settings-secrets.png └── vapor-entrypoint /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | # Based on https://github.com/actions/starter-workflows/blob/master/ci/docker-publish.yml 2 | 3 | name: Docker 4 | 5 | on: 6 | push: 7 | # Publish `master` as Docker `latest` image. 8 | branches: 9 | - master 10 | 11 | # Publish tags as releases. 12 | tags: 13 | - "**" 14 | 15 | # Run tests for any PRs. 16 | pull_request: 17 | 18 | env: 19 | # TODO: Change variable to your image's name. 20 | IMAGE_NAME: laravel-vapor-action 21 | 22 | jobs: 23 | # Run tests. 24 | # See also https://docs.docker.com/docker-hub/builds/automated-testing/ 25 | test: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - uses: actions/checkout@v2 30 | 31 | - name: Run tests 32 | run: | 33 | if [ -f docker-compose.test.yml ]; then 34 | docker-compose --file docker-compose.test.yml build 35 | docker-compose --file docker-compose.test.yml run sut 36 | else 37 | docker build . --file Dockerfile 38 | fi 39 | 40 | # Push image to GitHub Packages. 41 | # See also https://docs.docker.com/docker-hub/builds/ 42 | push: 43 | # Ensure test job passes before pushing image. 44 | needs: test 45 | 46 | runs-on: ubuntu-latest 47 | if: github.event_name == 'push' 48 | 49 | steps: 50 | - uses: actions/checkout@v2 51 | 52 | - name: Build image 53 | run: docker build . --file Dockerfile --tag image 54 | 55 | - name: Log into registry 56 | run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin 57 | 58 | - name: Push image 59 | run: | 60 | IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME 61 | 62 | # Change all uppercase to lowercase 63 | IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') 64 | 65 | # Strip git ref prefix from version 66 | VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') 67 | 68 | # Use Docker `latest` tag convention 69 | [ "$VERSION" == "master" ] && VERSION=latest 70 | 71 | echo IMAGE_ID=$IMAGE_ID 72 | echo VERSION=$VERSION 73 | 74 | docker tag image $IMAGE_ID:$VERSION 75 | docker push $IMAGE_ID:$VERSION 76 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `ubient/laravel-vapor-action` will be documented in this file 4 | 5 | ## 1.0.0 - 2019-09-25 6 | - Initial release 7 | 8 | ## 1.1.0 - 2020-04-05 9 | - New and improved approach (that supersedes this Action in a way) thanks to [@kurucu](https://github.com/kurucu). 10 | - Updated [README.md](README.md) 11 | 12 | ## 1.2.0 - 2020-04-29 13 | - Added automatic Docker Image building, tagging & publishing. 14 | - Added Docker Image method (allowing for the most performant build times so far!) 15 | 16 | ## 1.2.1 - 2020-06-15 17 | - Fixed PHP 7.4 support due to missing oniguruma library (required by PHP mbstring) 18 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 44 | 45 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 46 | 47 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 48 | 49 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 50 | 51 | **Happy coding**! 52 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM composer:2.0 2 | 3 | LABEL repository="https://github.com/ubient/laravel-vapor-action" 4 | LABEL homepage="https://github.com/ubient/laravel-vapor-action" 5 | LABEL maintainer="Claudio Dekker " 6 | 7 | # Install required extenstions for laravel 8 | # https://laravel.com/docs/6.x#server-requirements 9 | RUN apk add oniguruma-dev libxml2-dev && \ 10 | docker-php-ext-install bcmath xml tokenizer mbstring 11 | 12 | RUN set -xe && \ 13 | composer global require laravel/vapor-cli && \ 14 | composer clear-cache 15 | 16 | # Install Node.js (needed for Vapor's NPM Build) 17 | RUN apk add --update nodejs npm 18 | 19 | # Prepare out Entrypoint (used to run Vapor commands) 20 | COPY vapor-entrypoint /usr/local/bin/vapor-entrypoint 21 | 22 | ENTRYPOINT ["/usr/local/bin/vapor-entrypoint"] 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Ubient 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Latest Version](https://img.shields.io/github/release/ubient/laravel-vapor-action.svg?style=flat-square)](https://github.com/ubient/laravel-vapor-action/releases) 2 | 3 | # Laravel Vapor Action 4 | 5 | This Github Action is no longer maintained, and has been removed from the Github Marketplace. 6 | 7 | While this package will remain available/installable for the forseeable future, **this package WILL NOT be receiving any further (security) updates going forward**. Instead, you are recommended to use the significantly faster and more flexible approach as documented below: 8 | 9 | ![image](https://user-images.githubusercontent.com/1752195/121706739-33743d00-cad6-11eb-9885-95c32c472082.png) 10 | 11 | ## Replacement / recommended alternative approach 12 | 13 | Please note that you will need an active [Laravel Vapor](https://vapor.laravel.com) subscription. 14 | 15 | ### 1. Setting up a Github Secret 16 | In order to authenticate with Vapor from Github Actions, we will need to add a `VAPOR_API_TOKEN` [secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets) to your repository.\ 17 | To do so, you may do the following: 18 | 1. On GitHub, navigate to the main page of the repository you intend to use this action on. 19 | 2. Under your repository name, click `Settings`. 20 | 3. In the left sidebar, click `Secrets`. 21 | 4. Click `Add a new secret`. 22 | 5. For the name of your secret, enter `VAPOR_API_TOKEN`. 23 | 6. For the value itself, enter your Laravel Vapor API token. You may generate one in your [Vapor API settings dashboard](https://vapor.laravel.com/app/account/api-tokens). 24 | 7. Click `Add secret`. 25 | ![Example of the Project Settings Secrets page](/images/project-settings-secrets.png) 26 | 27 | ### 2. Setting up your Github Action 28 | 29 | Next, let's head over to the `Actions` page, and create a new workflow.\ 30 | To keep things simple, let's set up an action that deploys to production as soon as a branch is merged into master: 31 | 32 | ```yaml 33 | name: Deploy to production 34 | 35 | on: 36 | push: 37 | branches: [ master ] 38 | 39 | jobs: 40 | vapor: 41 | name: Check out, build and deploy using Vapor 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/checkout@v2 45 | - name: Setup PHP 46 | uses: shivammathur/setup-php@v2 47 | with: 48 | php-version: 8.0 49 | tools: composer:v2 50 | coverage: none 51 | - name: Require Vapor CLI 52 | run: composer global require laravel/vapor-cli 53 | - name: Deploy Environment 54 | run: vapor deploy 55 | env: 56 | VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} 57 | ``` 58 | 59 | #### Explanation 60 | 61 | The above does a few things: 62 | 1. It does a git checkout out your Laravel App (your repository) using the `actions/checkout` action. 63 | 2. It prepares your PHP environment using the amazing [shivammathur/setup-php](https://github.com/shivammathur/setup-php). 64 | 3. It installs the [Laravel Vapor CLI](https://docs.vapor.build/1.0/introduction.html#installing-the-vapor-cli) using Composer. 65 | 5. It executes the `vapor` CLI command using [the `deploy` argument](https://docs.vapor.build/1.0/projects/deployments.html#initiating-deployments). 66 | 67 | If you would like to find out more regarding the syntax used by Github Actions, you can take a look at [this page](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onevent_nametypes). 68 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Laravel Vapor' 2 | description: 'Run Laravel Vapor commands directly from Github Actions' 3 | author: 'Claudio Dekker ' 4 | branding: 5 | icon: 'upload-cloud' 6 | color: 'blue' 7 | runs: 8 | using: 'docker' 9 | image: 'Dockerfile' 10 | -------------------------------------------------------------------------------- /images/project-settings-secrets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubient/laravel-vapor-action/f306dd7122cc56247f9dc8d9d42d5560218b1b2f/images/project-settings-secrets.png -------------------------------------------------------------------------------- /vapor-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -z ${VAPOR_API_TOKEN} ]; then 6 | echo "To interact with Vapor directly from Github, you will need to add a VAPOR_API_TOKEN to your project secrets." >&2 7 | echo "You may generate an API token in your Vapor API settings dashboard: https://vapor.laravel.com/app/account/api-tokens" >&2 8 | exit 1 9 | fi 10 | 11 | composer global require laravel/vapor-cli --no-interaction --prefer-dist --quiet 12 | php $COMPOSER_HOME/vendor/bin/vapor "$@" -vvv 13 | exit $? 14 | --------------------------------------------------------------------------------