Skip to content

Commit c6eeac9

Browse files
committed
initial commit
0 parents  commit c6eeac9

File tree

4,280 files changed

+1160182
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,280 files changed

+1160182
-0
lines changed

.github/workflows/README.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Enhanced Run Script GitHub Action
2+
3+
This GitHub Action automatically runs the enhanced run script when a Pull Request is merged to the main branch.
4+
5+
## Overview
6+
7+
The enhanced run script is an automated browser testing tool that:
8+
- Uses Playwright for browser automation
9+
- Integrates with AI services (Gemini and OpenAI) for intelligent instruction generation
10+
- Takes screenshots of web applications
11+
- Supports multiple modes: `default`, `ui_change`, and `new_feature`
12+
13+
## Setup
14+
15+
### 1. Required Secrets
16+
17+
Add the following secrets to your GitHub repository:
18+
19+
1. Go to your repository → Settings → Secrets and variables → Actions
20+
2. Add the following repository secrets:
21+
22+
```
23+
GEMINI_API_KEY=your_gemini_api_key_here
24+
OPENAI_API_KEY=your_openai_api_key_here
25+
```
26+
27+
### 2. API Keys Setup
28+
29+
#### Gemini API Key
30+
- Visit [Google AI Studio](https://makersuite.google.com/app/apikey)
31+
- Create a new API key
32+
- Copy the key and add it as `GEMINI_API_KEY` secret
33+
34+
#### OpenAI API Key
35+
- Visit [OpenAI Platform](https://platform.openai.com/api-keys)
36+
- Create a new API key
37+
- Copy the key and add it as `OPENAI_API_KEY` secret
38+
39+
## How It Works
40+
41+
### Trigger
42+
The action is triggered when:
43+
- A Pull Request is closed
44+
- The PR was merged (not just closed)
45+
- The target branch is `main` or `master`
46+
47+
### Execution
48+
1. **Setup**: Installs Node.js, Python, and all dependencies
49+
2. **Matrix Strategy**: Runs the script in three different modes:
50+
- `default`: Standard translation mode
51+
- `ui_change`: For UI changes that require screenshot updates
52+
- `new_feature`: For new features that need screenshots
53+
3. **Execution**: Runs the enhanced script with the specified mode
54+
4. **Artifacts**: Uploads screenshots and logs as artifacts
55+
56+
### Modes
57+
58+
#### Default Mode
59+
- Standard translation mode
60+
- Takes screenshots for both English and Spanish documentation
61+
- Navigates through the application normally
62+
63+
#### UI Change Mode
64+
- Specifically for when UI elements have changed
65+
- Replaces existing screenshots due to UI updates
66+
- Focuses on updated interface elements
67+
68+
#### New Feature Mode
69+
- For capturing screenshots of new features
70+
- Takes screenshots for new functionality
71+
- Creates placeholder documentation
72+
73+
## Artifacts
74+
75+
The action creates the following artifacts:
76+
77+
### Screenshots
78+
- **Name**: `enhanced-run-screenshots-{mode}`
79+
- **Path**: `AutoSnap/screenshots/`
80+
- **Retention**: 30 days
81+
82+
### Logs
83+
- **Name**: `enhanced-run-logs-{mode}`
84+
- **Path**: `AutoSnap/*.log` and `AutoSnap/tracewrightt/*.log`
85+
- **Retention**: 30 days
86+
87+
## Troubleshooting
88+
89+
### Common Issues
90+
91+
1. **API Key Errors**
92+
- Ensure both `GEMINI_API_KEY` and `OPENAI_API_KEY` are set correctly
93+
- Check that the API keys have sufficient credits/quota
94+
95+
2. **Browser Issues**
96+
- The action uses Playwright with Chromium
97+
- If browser automation fails, check the logs for specific errors
98+
99+
3. **Timeout Issues**
100+
- The script has a 30-minute timeout
101+
- If it times out, check if the target website is accessible
102+
103+
4. **Dependency Issues**
104+
- Ensure all Node.js and Python dependencies are properly installed
105+
- Check the build logs for any missing packages
106+
107+
### Debugging
108+
109+
1. **Check Action Logs**
110+
- Go to Actions tab in your repository
111+
- Click on the failed workflow run
112+
- Review the step-by-step logs
113+
114+
2. **Download Artifacts**
115+
- Even if the script fails, artifacts are uploaded
116+
- Download logs and screenshots for analysis
117+
118+
3. **Local Testing**
119+
- Test the script locally before pushing changes
120+
- Ensure it works with your current API keys
121+
122+
## Customization
123+
124+
### Modify Modes
125+
To add or remove modes, edit the matrix strategy in `.github/workflows/enhanced-run-on-pr-merge.yml`:
126+
127+
```yaml
128+
strategy:
129+
matrix:
130+
mode: [default, ui_change, new_feature, your_custom_mode]
131+
```
132+
133+
### Change Timeout
134+
Modify the timeout in the "Run enhanced script" step:
135+
136+
```yaml
137+
timeout-minutes: 30 # Change this value
138+
```
139+
140+
### Add Notifications
141+
You can add Slack, Discord, or email notifications by adding additional steps to the workflow.
142+
143+
## Security Notes
144+
145+
- API keys are stored as GitHub secrets and are encrypted
146+
- Never commit API keys directly to the repository
147+
- Regularly rotate your API keys for security
148+
- Monitor API usage to avoid unexpected charges
149+
150+
## Support
151+
152+
If you encounter issues:
153+
1. Check the troubleshooting section above
154+
2. Review the action logs for specific error messages
155+
3. Ensure all dependencies and API keys are properly configured
156+
4. Test the script locally to isolate issues
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Deploy static webapp
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest #[self-hosted, linux] #
10+
name: 'Deploy static webapp'
11+
concurrency:
12+
group: ci-pipeline-master
13+
cancel-in-progress: false
14+
15+
steps:
16+
- uses: actions/[email protected]
17+
18+
- name: Use Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.x'
22+
- name: Install yarn
23+
run: npm install -g yarn
24+
- name: Install dependencies
25+
run: yarn install
26+
- name: Build Help Manual
27+
run: yarn run build
28+
29+
- name: Check and Install Azure CLI
30+
run: |
31+
if ! command -v az &> /dev/null; then
32+
echo "Azure CLI not found. Installing..."
33+
apt-get update
34+
apt-get install -y ca-certificates curl apt-transport-https lsb-release gnupg
35+
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/microsoft-azure-cli.gpg > /dev/null
36+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-azure-cli.gpg] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
37+
apt-get update
38+
apt-get install -y azure-cli
39+
else
40+
echo "Azure CLI is already installed."
41+
fi
42+
43+
- name: Verify Azure CLI Installation
44+
run: az --version
45+
46+
- name: Azure login
47+
env:
48+
AZURE_USERNAME: ${{ secrets.AZURE_USERNAME }}
49+
AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }}
50+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT }}
51+
run: |
52+
53+
az login -u $AZURE_USERNAME -p $AZURE_PASSWORD --tenant $AZURE_TENANT_ID -o none
54+
az account set --subscription 6b953fbc-42c0-40da-b8f1-8c5a99beaf8d
55+
56+
- name: Set up Terraform
57+
uses: hashicorp/[email protected]
58+
with:
59+
terraform_version: 1.8.4
60+
61+
- name: Terraform
62+
run: |
63+
terraform init --var-file="env.tfvars"
64+
terraform plan --var-file="env.tfvars" -out="terraform_plan.tfplan"
65+
terraform apply "terraform_plan.tfplan"
66+
67+
working-directory: ./terraform
68+
69+
- name: static app deploy
70+
env:
71+
HELPMANUALRG: po-shared
72+
AZURE_STORAGE_ACCOUNT_1: posharedhelpmanual01
73+
AZURE_STORAGE_ACCOUNT_2: posharedhelpmanual02
74+
75+
run: |
76+
77+
AZURE_STORAGE_KEY_1=$(az storage account keys list --resource-group $HELPMANUALRG --account-name $AZURE_STORAGE_ACCOUNT_1 --query "[].value" -o tsv)
78+
AZURE_STORAGE_KEY_2=$(az storage account keys list --resource-group $HELPMANUALRG --account-name $AZURE_STORAGE_ACCOUNT_2 --query "[].value" -o tsv)
79+
80+
TAG_1=$(az storage account show -g $HELPMANUALRG -n $AZURE_STORAGE_ACCOUNT_1 --query "tags.status || 'deactivated'" -o tsv)
81+
TAG_2=$(az storage account show -g $HELPMANUALRG -n $AZURE_STORAGE_ACCOUNT_2 --query "tags.status || 'deactivated'" -o tsv)
82+
83+
84+
if [[ "$TAG_1" == "deactivated" ]]; then
85+
TARGET_STORAGE_ACCOUNT="$AZURE_STORAGE_ACCOUNT_1"
86+
TARGET_STORAGE_KEY="$AZURE_STORAGE_KEY_1"
87+
NEXT_ACTIVE_ACCOUNT="$AZURE_STORAGE_ACCOUNT_2"
88+
else
89+
TARGET_STORAGE_ACCOUNT="$AZURE_STORAGE_ACCOUNT_2"
90+
TARGET_STORAGE_KEY="$AZURE_STORAGE_KEY_2"
91+
NEXT_ACTIVE_ACCOUNT="$AZURE_STORAGE_ACCOUNT_1"
92+
fi
93+
94+
95+
cat <<EOF >> $GITHUB_ENV
96+
TARGET_STORAGE_ACCOUNT=$TARGET_STORAGE_ACCOUNT
97+
TARGET_STORAGE_KEY=$TARGET_STORAGE_KEY
98+
NEXT_ACTIVE_ACCOUNT=$NEXT_ACTIVE_ACCOUNT
99+
EOF
100+
101+
102+
echo "Environment variables set successfully"
103+
echo "TARGET_STORAGE_ACCOUNT:$TARGET_STORAGE_ACCOUNT"
104+
echo "NEXT_ACTIVE_ACCOUNT:$NEXT_ACTIVE_ACCOUNT"
105+
106+
az storage blob upload-batch --account-name "$TARGET_STORAGE_ACCOUNT" --account-key "$TARGET_STORAGE_KEY" --source ./build --destination '$web' --overwrite
107+
108+
az storage account update --name $TARGET_STORAGE_ACCOUNT --set tags.status=activated
109+
az storage account update --name $NEXT_ACTIVE_ACCOUNT --set tags.status=deactivated
110+
111+
STORAGE_ENDPOINT=$(az storage account show \
112+
--name $TARGET_STORAGE_ACCOUNT \
113+
--query "primaryEndpoints.web" -o tsv)
114+
115+
echo "static endpoint:$STORAGE_ENDPOINT"
116+
117+
echo "STATIC_STORAGE_ENDPOINT=$STORAGE_ENDPOINT" >> $GITHUB_ENV
118+
119+
- name: Update Azure Front Door Backend Pool
120+
env:
121+
AZURE_SUBSCRIPTION_ID: "f164f104-f8a2-41dc-acf0-612199ae83ed"
122+
RESOURCE_GROUP: "RG-SCUS-FD"
123+
FRONT_DOOR_NAME: "omegaai-us-global"
124+
ENDPOINT: ${{ env.STATIC_STORAGE_ENDPOINT }}
125+
run: |
126+
az config set extension.dynamic_install_allow_preview=true
127+
128+
az account set --subscription $AZURE_SUBSCRIPTION_ID
129+
130+
FQDN=$(echo "$ENDPOINT" | sed 's|https://||;s|/$||')
131+
132+
echo "FQDN:$FQDN"
133+
134+
echo "before updating the front door backend pool"
135+
az afd origin list --profile-name "$FRONT_DOOR_NAME" --origin-group-name "help" --resource-group "$RESOURCE_GROUP"
136+
137+
az afd origin update \
138+
--profile-name "$FRONT_DOOR_NAME" \
139+
--name "help-1" \
140+
--origin-group-name "help" \
141+
--resource-group "$RESOURCE_GROUP" \
142+
--host-name "$FQDN" \
143+
--origin-host-header "$FQDN"
144+
145+
echo "after updating the front door backend pool"
146+
az afd origin list --profile-name "$FRONT_DOOR_NAME" --origin-group-name "help" --resource-group "$RESOURCE_GROUP"

0 commit comments

Comments
 (0)