├── .github └── workflows │ └── test-action.yml ├── Dockerfile ├── README.md ├── action.yml └── entrypoint.sh /.github/workflows/test-action.yml: -------------------------------------------------------------------------------- 1 | on: [push] 2 | 3 | jobs: 4 | test-action: 5 | runs-on: ubuntu-latest 6 | name: Test that we can use the htaccess tester 7 | steps: 8 | - name: Add a very basic htaccess file 9 | run: echo "RewriteRule .* /foo" >> .htaccess 10 | - name: Test that we can run this action 11 | uses: madewithlove/htaccess-cli-github-action@main 12 | with: 13 | url: http://localhost 14 | expected-url: http://localhost/foo 15 | 16 | test-failure: 17 | runs-on: ubuntu-latest 18 | name: Test that we can let a pipeline fail 19 | steps: 20 | - name: Add a very basic htaccess file 21 | run: echo "RewriteRule .* /foo" >> .htaccess 22 | - name: Test that we can run this action 23 | uses: madewithlove/htaccess-cli-github-action@main 24 | with: 25 | url: http://localhost 26 | expected-url: http://localhost/bar 27 | continue-on-error: true 28 | 29 | test-multiple-urls: 30 | runs-on: ubuntu-latest 31 | name: Test that multiple urls can be used 32 | steps: 33 | - name: Add a very basic htaccess file 34 | run: echo "RewriteRule .* /foo" >> .htaccess 35 | - name: Add an url-list file 36 | run: | 37 | echo "http://localhost/test: http://localhost/foo" >> url-list.yml 38 | echo "http://localhost/bar: http://localhost/foo" >> url-list.yml 39 | - name: Test that we can run this action 40 | uses: madewithlove/htaccess-cli-github-action@multiple 41 | with: 42 | url-list: url-list.yml 43 | 44 | test-multiple-urls-failure: 45 | runs-on: ubuntu-latest 46 | name: Test that multiple urls failure works 47 | steps: 48 | - name: Add a very basic htaccess file 49 | run: echo "RewriteRule .* /foo" >> .htaccess 50 | - name: Add an url-list file 51 | run: | 52 | echo "http://localhost/test: http://localhost/foo" >> url-list.yml 53 | echo "http://localhost/bar: http://localhost/wrong" >> url-list.yml 54 | - name: Test that we can run this action 55 | uses: madewithlove/htaccess-cli-github-action@multiple 56 | with: 57 | url-list: url-list.yml 58 | continue-on-error: true 59 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM composer:1.9 2 | 3 | LABEL "repository"="https://github.com/madewithlove/htaccess-cli-github-action" 4 | LABEL "homepage"="https://github.com/madewithlove/htaccess-cli-github-action" 5 | LABEL "maintainer"="Wouter Sioen " 6 | 7 | RUN composer global require --no-progress madewithlove/htaccess-cli 8 | 9 | COPY entrypoint.sh /usr/local/bin/entrypoint.sh 10 | ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Htaccess CLI GitHub Action 2 | 3 | This GitHub Action can be used to check if htaccess files in your repository behave the way you want them to. 4 | It uses the [Htaccess tester](https://htaccess.madewithlove.be/) and [Htaccess cli](https://github.com/madewithlove/htaccess-cli) under the hood. 5 | 6 | ## Usage 7 | 8 | Create your GitHub Workflow configuration in `.github/workflows/ci.yml` or similar. 9 | 10 | ```yaml 11 | name: CI 12 | 13 | on: [push] 14 | 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@v1 21 | - name: Test if htaccess files in current directory does wanted redirects 22 | uses: madewithlove/htaccess-cli-github-action@main 23 | with: 24 | url: http://localhost 25 | expected-url: http://localhost/foo 26 | ``` 27 | 28 | You can also run this on multiple urls when using the multiple branch 29 | 30 | We assume here that the url-list file is committed in the repository, 31 | you can also add it in the pipeline itself, which you can see in 32 | 33 | ```yaml 34 | name: CI 35 | 36 | on: [push] 37 | 38 | jobs: 39 | build: 40 | runs-on: ubuntu-latest 41 | 42 | steps: 43 | - uses: actions/checkout@v1 44 | - name: Test if htaccess files in current directory does multiple wanted redirects 45 | uses: madewithlove/htaccess-cli-github-action@multiple 46 | with: 47 | url-list: url-list.yml 48 | ``` 49 | 50 | 51 | The structure of the url-list file should look like this: 52 | 53 | ```yaml 54 | http://localhost/foo: http://localhost/test 55 | http://localhost/bar: http://localhost/test 56 | ``` 57 | 58 | Finally, you can supply a working directory for the action to run in. 59 | 60 | ```yaml 61 | name: CI 62 | 63 | on: [push] 64 | 65 | jobs: 66 | build: 67 | runs-on: ubuntu-latest 68 | 69 | steps: 70 | - uses: actions/checkout@v1 71 | - name: Test if htaccess files in a working directory is valid 72 | uses: madewithlove/htaccess-cli-github-actions@main 73 | with: 74 | url: http://localhost/ 75 | expected-url: http://localhost/foo 76 | working-directory: ./html 77 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Htaccess CLI' 2 | description: 'Runs the htaccess tester as a GitHub Action' 3 | inputs: 4 | url: 5 | description: 'The url to test the htaccess file against' 6 | required: true 7 | expected-url: 8 | description: 'The url you expect as output, CI will fail if this is not the real result' 9 | required: true 10 | working-directory: 11 | description: 'The working directory path' 12 | required: false 13 | 14 | runs: 15 | using: 'docker' 16 | image: 'Dockerfile' 17 | args: 18 | - ${{ inputs.url }} 19 | - --expected-url 20 | - ${{ inputs.expected-url }} 21 | - --path 22 | - ${{ inputs.working-directory}} 23 | 24 | branding: 25 | icon: 'heart' 26 | color: 'red' 27 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | PATH=/tmp/vendor/bin:$PATH 5 | htaccess "$@" 6 | --------------------------------------------------------------------------------