Skip to content

Commit 3d627c6

Browse files
committed
feat(workflow): add demo workflow for mage-remote-run integration
1 parent 7bbaa38 commit 3d627c6

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/demo.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Mage Remote Run Demo
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "main" ]
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
jobs:
11+
demo:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Install mage-remote-run
23+
run: npm install -g mage-remote-run
24+
25+
- name: Configure Connection
26+
# In a real scenario, use GitHub Secrets for all sensitive values
27+
env:
28+
MAGE_URL: ${{ secrets.MAGE_URL || 'https://example.com' }}
29+
MAGE_CONSUMER_KEY: ${{ secrets.MAGE_CONSUMER_KEY || 'ck' }}
30+
MAGE_CONSUMER_SECRET: ${{ secrets.MAGE_CONSUMER_SECRET || 'cs' }}
31+
MAGE_ACCESS_TOKEN: ${{ secrets.MAGE_ACCESS_TOKEN || 'at' }}
32+
MAGE_ACCESS_TOKEN_SECRET: ${{ secrets.MAGE_ACCESS_TOKEN_SECRET || 'ts' }}
33+
run: |
34+
mage-remote-run connection add \
35+
--name "MyOAuth" \
36+
--type "ac-on-prem" \
37+
--url "$MAGE_URL" \
38+
--consumer-key "$MAGE_CONSUMER_KEY" \
39+
--consumer-secret "$MAGE_CONSUMER_SECRET" \
40+
--access-token "$MAGE_ACCESS_TOKEN" \
41+
--token-secret "$MAGE_ACCESS_TOKEN_SECRET" \
42+
--active \
43+
--no-test
44+
45+
- name: Test Connection
46+
# This step will fail if the credentials above are invalid
47+
# We continue on error just to show the workflow completing for demo purposes
48+
continue-on-error: true
49+
run: mage-remote-run connection test

AGENTS.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Agent Guidelines
2+
3+
This repository demonstrates the integration of `mage-remote-run` within GitHub Actions.
4+
It contains workflow configurations to automated testing and usage of the `mage-remote-run` tool.
5+
6+
## 1. Build, Lint, and Test
7+
8+
Since this is a configuration repository for GitHub Actions, "building" and "testing" primarily involve validating the YAML workflows.
9+
10+
### Testing
11+
- **Local Validation**: Ensure `mage-remote-run` is installed locally to verify commands.
12+
```bash
13+
# Check version
14+
mage-remote-run --version
15+
16+
# Test connection (requires configured connection)
17+
mage-remote-run connection test
18+
```
19+
- **CI Validation**: The primary test is the GitHub Action itself defined in `.github/workflows/demo.yml`.
20+
21+
### Linting
22+
- **YAML**: Ensure all `.yml` files in `.github/workflows` are valid YAML.
23+
- **Action Syntax**: Follow standard GitHub Actions syntax.
24+
25+
## 2. Code Style & Conventions
26+
27+
### Workflows (YAML)
28+
- **Indentation**: Use 2 spaces for indentation.
29+
- **Naming**:
30+
- Jobs and steps should have clear, descriptive names.
31+
- Environment variables should be uppercase (e.g., `MAGE_URL`).
32+
- **Secrets**: NEVER hardcode credentials. Always use `${{ secrets.VARIABLE_NAME }}`.
33+
- `MAGE_URL`
34+
- `MAGE_CONSUMER_KEY`
35+
- `MAGE_CONSUMER_SECRET`
36+
- `MAGE_ACCESS_TOKEN`
37+
- `MAGE_ACCESS_TOKEN_SECRET`
38+
- **Shell Commands**:
39+
- Use `|` for multi-line commands to improve readability.
40+
- Quote all variables in bash scripts (e.g., `"$MAGE_URL"`).
41+
42+
### Tool Usage (`mage-remote-run`)
43+
- **Connection Setup**:
44+
- Use `connection add` with explicit flags for all parameters.
45+
- Always include `--no-test` in CI pipelines during the configuration step to separate configuration logic from connection verification.
46+
- Use `--active` to ensure the new connection is immediately usable.
47+
- **Command Structure**:
48+
```bash
49+
mage-remote-run connection add \
50+
--name "ProfileName" \
51+
--type "ac-on-prem" \
52+
... flags
53+
```
54+
55+
### Project Structure
56+
- `.github/workflows/`: Contains all CI/CD definitions.
57+
- `README.md`: Documentation for the example.
58+
59+
## 3. Error Handling
60+
- In CI steps that might fail due to missing secrets (like connection tests in a demo), use `continue-on-error: true` if the failure is expected or acceptable for the demonstration.
61+
- In production scripts, fail fast on error.
62+
63+
## 4. Updates
64+
- When updating the `mage-remote-run` version, check the [npm registry](https://www.npmjs.com/package/mage-remote-run) for the latest version and changelog.

0 commit comments

Comments
 (0)