Automate deploying websites and more to SMB shares with this GitHub action.
Place the following in /.github/workflows/main.yml
on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
- name: 📂 Sync all files
uses: pablo-schmeiser/SMB-Deploy-Action@latest
with:
smb_server: smb.pablo-schmeiser.com
smb_share: mySmbShare
smb_username: ${{ secrets.smb_username}}
smb_password: ${{ secrets.smb_password }}
- name: 📂 Sync index only
uses: pablo-schmeiser/SMB-Deploy-Action@latest
with:
smb_server: smb.pablo-schmeiser.com
smb_share: mySmbShare
smb_username: ${{ secrets.smb_username}}
smb_password: ${{ secrets.smb_password }}
source_path: index.html- You must have access to your SMB share on your server.
- Select the repository you want to add the action to
- Select the
Actionstab - Select
Blank workflow fileorSet up a workflow yourself, if you don't see these options manually create a yaml file underYour_Project/.github/workflows/main.yml - Paste the example above into your yaml file and save.
- Now you need to add a password and a username to the
secretssection in your project. To add asecretgo to theSettingstab in your project then selectSecrets. Add a newSecretforsmb_passwordand forsmb_username - Update your yaml file settings
- If you appreciate this github action give it a ⭐ or show off with one of the badges below.
Keys can be added directly to your .yml config files or referenced from your projects Secrets storage.
I strongly recommend you store your smb_password and your smb_username as a secret.
| Name | Required | Default | Description |
|---|---|---|---|
smb_server |
true | The IP address or hostname of the SMB server. | |
smb_share |
true | The name of the SMB share on the server (e.g., "MyFiles"). | |
smb_username |
true | The username to authenticate with the SMB server. | |
smb_password |
true | The password for the SMB username. Must be provided via secrets! | |
smb_domain |
false | Optional: The Windows domain name if the SMB server is part of one. | |
source_paths |
false | * | A space-separated list of file/directory paths AND/OR glob patterns to upload (relative to the repository root). |
destination_path |
false | / | The destination path on the SMB share (e.g., "/" for root, "/backup/data/"). |
You can use this action to publish your websites. The code here will only publish the index.html and the main.css files, but you can easily see how this could be useful.
name: Publish Index
on:
push:
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Download artifacts generated by build stage
- name: Download artifacts
uses: actions/download-artifact@v3
- name: "Upload release to SMB-Share"
uses: pablo-schmeiser/SMB-Deploy-Action@latest
with:
smb_server: smb.pablo-schmeiser.de
smb_share: mySmbShare
smb_username: ${{ secrets.USERNAME }}
smb_password: ${{ secrets.PASSWORD }}
source_paths: index.html main.cssSome people use this action to mirror the current state of LaTeX projects to their organizations internal SMB-Shares. The following achieves this:
name: Publish PDFs
on:
push:
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Download artifacts generated by build stage
- name: Download artifacts
uses: actions/download-artifact@v3
- name: "Create src folder"
run: mkdir src
- name: "Checkout to get source"
uses: actions/checkout@v3
with:
path: ./src
- name: "Upload release to internal SMB-Share"
uses: pablo-schmeiser/SMB-Deploy-Action@latest
with:
smb_server: smb.pablo-schmeiser.de
smb_share: mySmbShare
smb_username: ${{ secrets.USERNAME }}
smb_password: ${{ secrets.PASSWORD }}
destination_path: contractsIf you appreciate this github action give it a ⭐ or show off with one of the badges below. Feel free to edit the text or color.
[<img alt="Deployed with SMB Deploy Action" src="https://img.shields.io/badge/Deployed With-SMB DEPLOY ACTION-%3CCOLOR%3E?style=for-the-badge&color=0077b6">](https://github.com/pablo-schmeiser/SMB-Deploy-Action)How do I set a upload timeout?
github has a built-in timeout-minutes option, see customized example below
on: push
name: Publish
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
timeout-minutes: 15 # time out after 15 minutes (default is 360 minutes)
steps:
...This action is a basic wrapper around my @pablo-schmeiser/SMB-Deploy-Action repository. To test your config you can install @pablo-schmeiser/SMB-Deploy-Action and then convert your config to a yml action. Settings are one-to-one, this action is only a wrapper.
To test this action locally you will need to setup docker and act to run a environment similar to the one github uses for actions.
- Download/install docker, make sure it is running.
- install act
- Clone the @pablo-schmeiser/SMB-Deploy-Action git repository.
- Run the action by using act with
act -W './action.yml'