Skip to content

Commit 7b4b1a9

Browse files
committed
Added environment variables...
1 parent 8f68da3 commit 7b4b1a9

8 files changed

Lines changed: 622 additions & 20 deletions

File tree

.github/workflows/example.yml

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,56 @@ jobs:
3939
echo "Running system maintenance..."
4040
df -h
4141
free -m
42-
echo "Maintenance completed!"
42+
echo "Maintenance completed!"
43+
44+
- name: Deploy with environment variables
45+
uses: ./
46+
with:
47+
host: ${{ secrets.SERVER_HOST }}
48+
username: ${{ secrets.SERVER_USER }}
49+
password: ${{ secrets.SERVER_PASSWORD }}
50+
envs: 'DEPLOY_ENV=staging,APP_VERSION=1.0.0,NODE_ENV=production'
51+
script: |
52+
#!/bin/bash
53+
echo "=== Deployment with Environment Variables ==="
54+
echo "Environment: $DEPLOY_ENV"
55+
echo "App Version: $APP_VERSION"
56+
echo "Node Environment: $NODE_ENV"
57+
58+
# Example usage of environment variables
59+
if [ "$DEPLOY_ENV" = "production" ]; then
60+
echo "🚀 Production deployment detected"
61+
else
62+
echo "🧪 Staging deployment detected"
63+
fi
64+
65+
echo "Deployment completed!"
66+
67+
- name: Complex environment variables example
68+
uses: ./
69+
with:
70+
host: ${{ secrets.SERVER_HOST }}
71+
username: ${{ secrets.SERVER_USER }}
72+
password: ${{ secrets.SERVER_PASSWORD }}
73+
envs: |
74+
DATABASE_URL=${{ secrets.DATABASE_URL }},
75+
API_KEY=${{ secrets.API_KEY }},
76+
DEBUG=true,
77+
LOG_LEVEL=info,
78+
MAX_CONNECTIONS=100
79+
script: |
80+
#!/bin/bash
81+
echo "=== Complex Environment Variables Test ==="
82+
echo "Database configured: $([ -n "$DATABASE_URL" ] && echo "✅ Yes" || echo "❌ No")"
83+
echo "API Key configured: $([ -n "$API_KEY" ] && echo "✅ Yes" || echo "❌ No")"
84+
echo "Debug mode: $DEBUG"
85+
echo "Log level: $LOG_LEVEL"
86+
echo "Max connections: $MAX_CONNECTIONS"
87+
88+
# Example of conditional logic based on environment variables
89+
if [ "$DEBUG" = "true" ]; then
90+
echo "🐛 Debug mode enabled - showing detailed information"
91+
env | grep -E "(DATABASE_URL|API_KEY|DEBUG|LOG_LEVEL|MAX_CONNECTIONS)" | sed 's/=.*/=***/'
92+
fi
93+
94+
echo "Environment variables test completed!"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Marketplace Publication Check
2+
3+
on:
4+
schedule:
5+
- cron: '0 */6 * * *' # Check every 6 hours
6+
workflow_dispatch: # Allow manual trigger
7+
issues:
8+
types: [opened, edited]
9+
10+
permissions:
11+
contents: read
12+
issues: write
13+
14+
jobs:
15+
check-marketplace-status:
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
18+
19+
steps:
20+
- name: Check Marketplace Publication Status
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
echo "🔍 Checking marketplace publication status..."
25+
26+
# Get repository name parts
27+
REPO_OWNER=$(echo ${{ github.repository }} | cut -d'/' -f1)
28+
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
29+
30+
# Check if action is published to marketplace
31+
MARKETPLACE_URL="https://github.com/marketplace/actions/$REPO_NAME"
32+
33+
# Try to check if the action exists on marketplace
34+
if curl -s -o /dev/null -w "%{http_code}" "$MARKETPLACE_URL" | grep -q "200"; then
35+
echo "✅ Action found on GitHub Marketplace: $MARKETPLACE_URL"
36+
37+
# Find and close open marketplace publication issues
38+
gh issue list --repo ${{ github.repository }} --state open --label "marketplace" --json number,title | \
39+
jq -r '.[] | select(.title | contains("Publish") and contains("to GitHub Marketplace")) | .number' | \
40+
while read -r issue_number; do
41+
if [ -n "$issue_number" ]; then
42+
echo "📝 Closing marketplace publication issue #$issue_number"
43+
gh issue close $issue_number --repo ${{ github.repository }} --comment "🎉 **Marketplace Publication Completed!**
44+
45+
✅ This action has been successfully published to GitHub Marketplace!
46+
47+
🔗 **Marketplace URL**: $MARKETPLACE_URL
48+
49+
📦 **Usage**:
50+
\`\`\`yaml
51+
uses: ${{ github.repository }}@v1
52+
\`\`\`
53+
54+
🎯 The action is now available for the community to discover and use.
55+
56+
*This issue was automatically closed by the marketplace check workflow.*"
57+
fi
58+
done
59+
else
60+
echo "⏳ Action not yet published to marketplace or not accessible"
61+
echo "🔗 Expected marketplace URL: $MARKETPLACE_URL"
62+
fi
63+
64+
close-marketplace-issue:
65+
runs-on: ubuntu-latest
66+
if: github.event_name == 'issues' && github.event.action == 'opened' && contains(github.event.issue.title, 'Marketplace publication completed')
67+
68+
steps:
69+
- name: Auto-close completed marketplace issues
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
echo "🔄 Processing marketplace completion notification..."
74+
75+
# If someone manually reports marketplace publication completion
76+
if echo "${{ github.event.issue.body }}" | grep -q -i "published\|completed\|live"; then
77+
echo "✅ Marketplace publication reported as completed"
78+
79+
# Close the original publication tracking issue
80+
gh issue close ${{ github.event.issue.number }} --repo ${{ github.repository }} --comment "🎉 Thank you for confirming the marketplace publication!
81+
82+
✅ **Action successfully published to GitHub Marketplace**
83+
84+
🔗 Users can now discover and use this action from the marketplace.
85+
86+
📦 **Usage**:
87+
\`\`\`yaml
88+
uses: ${{ github.repository }}@v1
89+
\`\`\`"
90+
fi

.github/workflows/release.yml

Lines changed: 198 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
- ✅ Configurable SSH port (default: 22)
7272
- ✅ Password authentication with sshpass
7373
- ✅ Multi-line script support
74+
- ✅ Environment variables support (comma-separated)
7475
- ✅ Proper error handling and validation
7576
- ✅ Security best practices
7677
@@ -85,6 +86,18 @@ jobs:
8586
script: |
8687
echo "Hello from remote server!"
8788
uptime
89+
90+
# With environment variables
91+
- name: Deploy with environment variables
92+
uses: your-username/ssh-action@${{ steps.version.outputs.version }}
93+
with:
94+
host: ${{ secrets.SERVER_HOST }}
95+
username: ${{ secrets.SERVER_USER }}
96+
password: ${{ secrets.SERVER_PASSWORD }}
97+
envs: 'DEPLOY_ENV=production,APP_VERSION=1.2.3'
98+
script: |
99+
echo "Deploying version $APP_VERSION to $DEPLOY_ENV"
100+
# Your deployment script here
88101
```
89102
90103
### Security
@@ -108,23 +121,103 @@ jobs:
108121
--notes-file release_notes.md \
109122
--latest
110123
111-
- name: Marketplace Publication Info
124+
- name: Validate Marketplace Requirements
125+
run: |
126+
echo "🔍 Validating GitHub Marketplace requirements..."
127+
128+
# Check if repository is public
129+
REPO_VISIBILITY=$(gh repo view ${{ github.repository }} --json visibility --jq '.visibility')
130+
if [ "$REPO_VISIBILITY" != "public" ]; then
131+
echo "❌ Repository must be public for marketplace publication"
132+
echo " Go to Settings → Change repository visibility → Make public"
133+
exit 1
134+
fi
135+
echo "✅ Repository is public"
136+
137+
# Check action.yml branding
138+
if grep -q "branding:" action.yml && grep -q "icon:" action.yml && grep -q "color:" action.yml; then
139+
echo "✅ action.yml has proper branding configuration"
140+
else
141+
echo "❌ action.yml missing branding configuration"
142+
exit 1
143+
fi
144+
145+
# Check README exists and has content
146+
if [ -f README.md ] && [ -s README.md ]; then
147+
echo "✅ README.md exists and has content"
148+
else
149+
echo "❌ README.md missing or empty"
150+
exit 1
151+
fi
152+
153+
# Check for usage examples in README
154+
if grep -q "```yaml" README.md; then
155+
echo "✅ README contains usage examples"
156+
else
157+
echo "⚠️ README should include usage examples"
158+
fi
159+
160+
echo "🎯 Marketplace requirements validation complete!"
112161
env:
113162
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
164+
- name: Prepare Marketplace Metadata
165+
run: |
166+
echo "📋 Preparing marketplace metadata..."
167+
168+
# Create marketplace metadata file for reference
169+
cat > marketplace-metadata.json << 'EOF'
170+
{
171+
"name": "SSH Remote Script Executor",
172+
"description": "Execute scripts on remote hosts via SSH with password authentication",
173+
"categories": ["Deployment", "Utilities"],
174+
"tags": ["ssh", "remote", "deployment", "scripts", "automation"],
175+
"suggested_keywords": [
176+
"ssh",
177+
"remote-execution",
178+
"deployment",
179+
"server-management",
180+
"automation",
181+
"devops"
182+
],
183+
"marketplace_url": "https://github.com/marketplace/actions/ssh-remote-script-executor"
184+
}
185+
EOF
186+
187+
echo "✅ Marketplace metadata prepared"
188+
cat marketplace-metadata.json
189+
190+
- name: Auto-Open Marketplace Publication
114191
run: |
192+
echo "🚀 Opening marketplace publication page..."
193+
echo ""
115194
echo "🎉 Release created successfully!"
116-
echo "📦 Your action will be automatically available on GitHub Marketplace"
195+
echo "📦 Version: ${{ steps.version.outputs.version }}"
117196
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
118197
echo ""
119-
echo "ℹ️ To publish to GitHub Marketplace:"
120-
echo " 1. Ensure your repository is public"
121-
echo " 2. The action.yml file has proper branding (✅ already configured)"
122-
echo " 3. Go to your repository's main page"
123-
echo " 4. Click 'Publish this Action to the GitHub Marketplace'"
124-
echo " 5. Fill in the marketplace details and submit"
198+
echo "🏪 MARKETPLACE PUBLICATION:"
199+
echo " 📋 All requirements validated ✅"
200+
echo " 🔗 Publication URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
201+
echo ""
202+
echo "📝 To complete marketplace publication:"
203+
echo " 1. 🌐 Go to: https://github.com/${{ github.repository }}"
204+
echo " 2. 📦 Look for 'Publish this Action to the GitHub Marketplace' banner"
205+
echo " 3. 🖱️ Click the banner or go to the Releases tab"
206+
echo " 4. ✏️ Fill in the marketplace form with suggested details:"
207+
echo " - Name: SSH Remote Script Executor"
208+
echo " - Description: Execute scripts on remote hosts via SSH"
209+
echo " - Categories: Deployment, Utilities"
210+
echo " - Tags: ssh, remote, deployment, scripts, automation"
211+
echo " 5. 📤 Submit for publication"
125212
echo ""
126-
echo "📊 You can also view the release directly:"
127-
gh release view ${{ steps.version.outputs.version }} --web || echo " View at: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
213+
echo "🎯 The action will be reviewed and published to GitHub Marketplace!"
214+
echo "📊 View release: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
215+
216+
# Try to open the marketplace page (this works in some environments)
217+
echo "🔗 Attempting to open marketplace publication page..."
218+
gh repo view ${{ github.repository }} --web || echo " Manual navigation required"
219+
env:
220+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128221

129222
# Job to create/update major version tag (e.g., v1, v2)
130223
update-major-tag:
@@ -169,4 +262,98 @@ jobs:
169262
git push origin ${{ steps.major_version.outputs.major_version }}
170263
171264
echo "✅ Updated major version tag: ${{ steps.major_version.outputs.major_version }}"
172-
echo "🎯 Users can now use: uses: ${{ github.repository }}@${{ steps.major_version.outputs.major_version }}"
265+
echo "🎯 Users can now use: uses: ${{ github.repository }}@${{ steps.major_version.outputs.major_version }}"
266+
267+
# Job to create marketplace publication tracking issue
268+
create-marketplace-issue:
269+
runs-on: ubuntu-latest
270+
needs: [release, update-major-tag]
271+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
272+
273+
permissions:
274+
contents: write
275+
issues: write
276+
277+
steps:
278+
- name: Extract version from tag
279+
id: version
280+
run: |
281+
TAG_NAME=${GITHUB_REF#refs/tags/}
282+
echo "version=$TAG_NAME" >> $GITHUB_OUTPUT
283+
echo "version_number=${TAG_NAME#v}" >> $GITHUB_OUTPUT
284+
285+
- name: Create Marketplace Publication Issue
286+
env:
287+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
288+
run: |
289+
# Check if an issue already exists for this release
290+
EXISTING_ISSUE=$(gh issue list --repo ${{ github.repository }} --state open --search "Publish ${{ steps.version.outputs.version }} to GitHub Marketplace" --json number --jq '.[0].number' || echo "")
291+
292+
if [ -n "$EXISTING_ISSUE" ] && [ "$EXISTING_ISSUE" != "null" ]; then
293+
echo "📝 Issue already exists for this release: #$EXISTING_ISSUE"
294+
exit 0
295+
fi
296+
297+
# Create the issue
298+
gh issue create \
299+
--repo ${{ github.repository }} \
300+
--title "🏪 Publish ${{ steps.version.outputs.version }} to GitHub Marketplace" \
301+
--assignee ${{ github.actor }} \
302+
--label "marketplace,release" \
303+
--body "## 🚀 Release ${{ steps.version.outputs.version }} Ready for Marketplace Publication
304+
305+
### ✅ Pre-publication Checklist
306+
- [x] Release created successfully
307+
- [x] Major version tag updated
308+
- [x] All marketplace requirements validated
309+
- [x] Docker image builds successfully
310+
- [x] Action metadata configured
311+
- [ ] **Marketplace publication completed**
312+
313+
### 🏪 Marketplace Publication Steps
314+
315+
1. **Navigate to Repository**
316+
- Go to: https://github.com/${{ github.repository }}
317+
- Look for the \"Publish this Action to the GitHub Marketplace\" banner
318+
319+
2. **Click Publication Banner**
320+
- The banner should appear at the top of the repository page
321+
- If not visible, go to the Releases tab and click \"Publish to Marketplace\"
322+
323+
3. **Fill Marketplace Form**
324+
- **Name**: \`SSH Remote Script Executor\`
325+
- **Description**: \`Execute scripts on remote hosts via SSH with password authentication\`
326+
- **Categories**: \`Deployment\`, \`Utilities\`
327+
- **Tags**: \`ssh\`, \`remote\`, \`deployment\`, \`scripts\`, \`automation\`
328+
329+
4. **Submit for Review**
330+
- Review the information and submit
331+
- GitHub will review the action before publishing
332+
333+
### 📋 Marketplace Metadata
334+
335+
\`\`\`json
336+
{
337+
\"name\": \"SSH Remote Script Executor\",
338+
\"description\": \"Execute scripts on remote hosts via SSH with password authentication\",
339+
\"categories\": [\"Deployment\", \"Utilities\"],
340+
\"tags\": [\"ssh\", \"remote\", \"deployment\", \"scripts\", \"automation\"],
341+
\"version\": \"${{ steps.version.outputs.version }}\"
342+
}
343+
\`\`\`
344+
345+
### 🔗 Quick Links
346+
- [Release Page](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }})
347+
- [Repository](https://github.com/${{ github.repository }})
348+
- [Action Documentation](https://github.com/${{ github.repository }}/blob/main/README.md)
349+
350+
### 📝 Notes
351+
- This issue will be automatically closed when the marketplace publication is complete
352+
- The action will be available at: \`uses: ${{ github.repository }}@${{ steps.version.outputs.version }}\`
353+
- Major version tag available: \`uses: ${{ github.repository }}@v$(echo ${{ steps.version.outputs.version }} | cut -d. -f1 | sed 's/v//')\`
354+
355+
**Assigned to**: @${{ github.actor }}
356+
**Release**: ${{ steps.version.outputs.version }}
357+
**Status**: Ready for marketplace publication"
358+
359+
echo "📝 Created marketplace publication tracking issue"

0 commit comments

Comments
 (0)