├── acsweb ├── entrypoint.sh ├── Dockerfile ├── action.yml └── README.md ├── LICENSE └── README.md /acsweb/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # "to avoid continuing when errors or undefined variables are present" 4 | set -eu 5 | 6 | echo "Starting a UCSD ACSWeb Deploy to $INPUT_USERNAME acsweb.ucsd.edu... " 7 | 8 | sshpass -p $INPUT_PASSWORD rsync -vzr --delete --exclude '.*' -e 'ssh -o StrictHostKeyChecking=no' $INPUT_LOCAL_DIR $INPUT_USERNAME@acsweb.ucsd.edu:~/public_html/$INPUT_REMOTE_DIR 9 | 10 | echo "UCSD ACSWeb Deploy complete! 🚀" 11 | exit 0 12 | -------------------------------------------------------------------------------- /acsweb/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.10 2 | 3 | LABEL version="1.0.0" 4 | LABEL repository="https://github.com/os-ucsd/actions" 5 | LABEL homepage="https://github.com/os-ucsd/actions" 6 | LABEL maintainer="Alex Garcia " 7 | 8 | LABEL "com.github.actions.name"="UCSD ACSWeb Site Deploy" 9 | LABEL "com.github.actions.description"="Sync your personal or org website to your acsweb.ucsd.edu site!" 10 | LABEL "com.github.actions.icon"="upload-cloud" 11 | LABEL "com.github.actions.color"="blue" 12 | 13 | RUN apk update 14 | RUN apk add --update --no-cache openssh sshpass rsync 15 | 16 | 17 | COPY entrypoint.sh /entrypoint.sh 18 | RUN chmod 777 entrypoint.sh 19 | ENTRYPOINT ["/entrypoint.sh"] 20 | -------------------------------------------------------------------------------- /acsweb/action.yml: -------------------------------------------------------------------------------- 1 | name: 'UCSD ACSWeb Site Deploy' 2 | author: 'Open Source @ UCSD' 3 | description: 'Sync your personal or org website to your acsweb.ucsd.edu site!' 4 | inputs: 5 | username: 6 | description: 'The UCSD username where the acsweb site is hosted (e.g. asg017, os-ucsd, eceusc)' 7 | required: true 8 | password: 9 | description: 'The password for the UCSD username of the acsweb site. Put this inside a Github Secret!' 10 | required: true 11 | local_dir: 12 | description: 'The directory in the repository that contains the files you want to deploy' 13 | required: false 14 | default: "./" 15 | remote_dir: 16 | description: 'Any folder within `public_html` that you want to sync files to' 17 | required: false 18 | default: "" 19 | runs: 20 | using: 'docker' 21 | image: 'Dockerfile' 22 | args: 23 | - ${{ inputs.username }} 24 | - ${{ inputs.password }} 25 | - ${{ inputs.local_dir }} 26 | - ${{ inputs.remote_dir }} 27 | branding: 28 | icon: 'upload-cloud' 29 | color: 'blue' 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Open Source @ UCSD 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 | # Open Source @ UCSD Github Actions 🎬 2 | 3 | Github Actions written by the Open Source community at UC San Diego! 4 | 5 | ## About 6 | 7 | This repository contains [Github Actions](https://github.com/features/actions) - which are small actions people can use in Github workflows to automate certain tasks. The actions in this repository will be more specific to the open source community at UCSD, but anyone can use them or contribute back! 8 | 9 | Every directory in this repo is a separate Github Action - for example, the `/acsweb` directory contains a Github Action for deploying UCSD acsweb sites. 10 | 11 | ## Actions 12 | 13 | ### [`acsweb`](acsweb) - Deploy a Github repo to an ascweb.ucsd.edu site! 14 | 15 | If you have a UCSD personal site hosted at `https://acsweb.ucsd.edu/~username`, or your student org has a site at `orgname.ucsd.edu`, you can use this action to sync a Github repository to that site, with just a few lines of code! 16 | 17 | See [`acsweb/README.md`](acsweb/README.md) for details and examples. 18 | 19 | 20 | ## Contributing 21 | 22 | Do you want to add an action to this repo, or help fix one? Feel free to fork this repo, send PR's, or file issues to help improve this project! 23 | -------------------------------------------------------------------------------- /acsweb/README.md: -------------------------------------------------------------------------------- 1 | # UCSD ACSWeb Site Deploy Github Action 2 | 3 | Deploy your personal or organization website to an acsweb.ucsd.edu account, all on Github! 4 | 5 | 6 | **Warning before you use this**: If you have any files in your ascsweb web account under `public_html`, it will be deleted if you use this action! Make sure to backup anything you have before running this action. 7 | 8 | ## Inputs 9 | 10 | ### `username` 11 | 12 | **Required** The username of the acsweb account that you want to deploy to. 13 | 14 | ### `password` 15 | 16 | **Required** The password to your acsweb account listed above. 17 | 18 | WARNING: Make sure you make a [Github secret](https://help.github.com/en/github/automating-your-workflow-with-github-actions/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) for this field! Do NOT put your raw password here! 19 | 20 | ### `local_dir` 21 | 22 | **Optional** A specific directory inside of your git repo that you want to sync. Default "./" (the root of your git repo). 23 | 24 | NOTE: If you define this, make sure it ends in a `/` ! If not, the `rsync` command may deploy the directory into the site, and not just the contents of the directory. 25 | 26 | ### `remote_dir` 27 | 28 | **Optional** A specfic directory in your acsweb account that you want to deploy to. For example, if you want to deploy to `org.ucsd.edu/events`, then have `remote_dir: "./events/"`. We haven't tested this yet, so if you run into any problems create an issue above and we can work it out! 29 | 30 | ## Example usage 31 | 32 | ### Minimal setup - http://acsweb.ucsd.edu/~asg017 33 | 34 | The repo is [here](https://github.com/asg017/my-acsweb-site), and the site is live [here](http://acsweb.ucsd.edu/~asg017/). This is the most minimal example of this Github action that you could do. If you want to sync all files in a repository WITHOUT any preprocessng (e.g. building a React app, Jekyll, etc.), then this is what you want! 35 | 36 | #### `.github/workflows/main.yml` 37 | 38 | ```yml 39 | name: Deploy 40 | 41 | # Only deploy when pushing to master (and not other branches) 42 | on: 43 | push: 44 | branches: 45 | - master 46 | 47 | jobs: 48 | build: 49 | 50 | runs-on: ubuntu-latest 51 | 52 | # Checkout the repo, then deploy all files to the asg017 account 53 | steps: 54 | - uses: actions/checkout@v1 55 | - uses: asg017/actions/acsweb@master 56 | with: 57 | username: asg017 58 | password: "${{secrets.password}}" 59 | ``` 60 | 61 | 62 | ### A React app - http://eceusc.ucsd.edu 63 | 64 | The repo is [here](https://github.com/eceusc/eceusc.ucsd.edu), and the live site exsts [here](http://eceusc.ucsd.edu/). 65 | 66 | This site is a little more complex than the example above. The repo contains a [React app](https://reactjs.org/), not a raw website. So, we first have to compile the React app down to normal `.html` and `.js` files, and then only sync those compiled files to our site. 67 | 68 | The final [workflow](https://github.com/eceusc/eceusc.ucsd.edu/blob/master/.github/workflows/main.yml) looks like this: 69 | 70 | ``` 71 | name: Deploy to eceusc.ucsd.edu 72 | 73 | on: 74 | push: 75 | branches: 76 | - master 77 | 78 | jobs: 79 | build: 80 | 81 | runs-on: ubuntu-latest 82 | 83 | steps: 84 | # Checkout the repository 85 | - uses: actions/checkout@v1 86 | 87 | # Setup node (used to download the React app's dependencies and to build the app) 88 | - uses: actions/setup-node@v1.1.0 89 | 90 | # Install the React app's dependencies 91 | - run: npm install 92 | 93 | # Build the React app itself 94 | - run: npm run build 95 | 96 | # Deploy the compiled result to the eceusc acsweb account 97 | - uses: asg017/actions/acsweb@master 98 | with: 99 | username: eceusc 100 | password: "${{secrets.ACSWEB_PASSWORD}}" 101 | 102 | # `npm run build` above compiles the React app to normal `.html` and `.js` files inside of 103 | # the `build` directory. So, let's just sync those files 104 | local_dir: "./build/" 105 | ``` 106 | 107 | ## Caveats 108 | 109 | ### Hidden files are not synced 110 | 111 | If the repo/directory that you're syncing has any hidden files, it will NOT be synced. This is because you probably don't want to sync your `.git` folder to a public facing website. So, this does not sync any hidden files to your acsweb site. 112 | 113 | If you do want this as a feature, feel free to open a Github issue above and we can work it out! 114 | 115 | ### Host Checking is turned off 116 | 117 | This action doesn't check the host before deploying your site, because of how Github Actions are ran. If you're just building a personal site and don't care too much about this, you probably don't have worry about this. If you're building something crazier and really care about security, then definitely make sure you understand this before using. But TBH since you're already making your site "public" by putting it on acsweb, the scope for this being abused is pretty low, I beleive. 118 | --------------------------------------------------------------------------------