Check Upstream Firefox Release #202
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check Upstream Firefox Release | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6 AM UTC | |
| workflow_dispatch: # Manual trigger | |
| # Prevent concurrent runs | |
| concurrency: | |
| group: upstream-firefox-check | |
| cancel-in-progress: false | |
| jobs: | |
| check-upstream: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_update: ${{ steps.check.outputs.should_update }} | |
| latest_tag: ${{ steps.check.outputs.latest_tag }} | |
| tracked_version: ${{ steps.check.outputs.tracked_version }} | |
| branch_name: ${{ steps.check.outputs.branch_name }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Check for new upstream release | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Get latest release from jlesage/docker-firefox | |
| LATEST_TAG=$(gh api repos/jlesage/docker-firefox/releases/latest --jq '.tag_name') | |
| echo "Latest upstream: $LATEST_TAG" | |
| BRANCH_NAME="update-upstream-$LATEST_TAG" | |
| echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| # Check tracked version | |
| TRACKED=$(cat .upstream-version 2>/dev/null || echo "none") | |
| echo "Currently tracking: $TRACKED" | |
| echo "tracked_version=$TRACKED" >> $GITHUB_OUTPUT | |
| if [ "$LATEST_TAG" != "$TRACKED" ]; then | |
| echo "π New release detected!" | |
| echo "should_update=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "β Already up to date" | |
| echo "should_update=false" >> $GITHUB_OUTPUT | |
| fi | |
| update-addon: | |
| needs: check-upstream | |
| if: needs.check-upstream.outputs.should_update == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Check if PR already exists or was skipped | |
| id: pr_check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BRANCH_NAME="${{ needs.check-upstream.outputs.branch_name }}" | |
| # Check for open PR | |
| OPEN_PR=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq '.[0].number // empty') | |
| if [ -n "$OPEN_PR" ]; then | |
| echo "PR #$OPEN_PR already open for branch $BRANCH_NAME" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Check for closed PR (not merged = intentionally skipped) | |
| CLOSED_PR=$(gh pr list --head "$BRANCH_NAME" --state closed --json number,mergedAt --jq '.[] | select(.mergedAt == null) | .number' | head -1) | |
| if [ -n "$CLOSED_PR" ]; then | |
| echo "PR #$CLOSED_PR was closed without merge - skipping this version" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "No existing or skipped PR found for branch $BRANCH_NAME" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| - name: Setup Git | |
| if: steps.pr_check.outputs.skip != 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Create branch | |
| if: steps.pr_check.outputs.skip != 'true' | |
| run: | | |
| BRANCH_NAME="${{ needs.check-upstream.outputs.branch_name }}" | |
| git checkout -b "$BRANCH_NAME" | |
| echo "BRANCH=$BRANCH_NAME" >> $GITHUB_ENV | |
| - name: Run Claude to update addon | |
| if: steps.pr_check.outputs.skip != 'true' | |
| uses: anthropics/claude-code-action@v1 | |
| with: | |
| claude_args: | | |
| --allowedTools "Read,Edit,Write,Glob,Grep,WebFetch,Bash" | |
| prompt: | | |
| A new version of jlesage/docker-firefox has been released: ${{ needs.check-upstream.outputs.latest_tag }} | |
| The currently tracked version is: ${{ needs.check-upstream.outputs.tracked_version }} | |
| Please update this Home Assistant add-on to use the new upstream version. | |
| ## Step 1: Fetch upstream release notes (ALL intermediate releases) | |
| IMPORTANT: There may be MULTIPLE upstream releases between our tracked version (${{ needs.check-upstream.outputs.tracked_version }}) and the latest (${{ needs.check-upstream.outputs.latest_tag }}). | |
| You MUST fetch and include release notes for ALL intermediate versions, not just the latest one. | |
| 1. Fetch the list of all releases: https://api.github.com/repos/jlesage/docker-firefox/releases?per_page=20 | |
| 2. Parse the JSON array and identify ALL releases that are NEWER than ${{ needs.check-upstream.outputs.tracked_version }} (up to and including ${{ needs.check-upstream.outputs.latest_tag }}) | |
| 3. For each intermediate release, extract the "tag_name" and "body" fields | |
| 4. You MUST include the changes from ALL intermediate releases in the changelog entries later, not just the latest one | |
| 5. If a release contains significant Firefox-specific changes (not just baseimage updates), note this for version bumping decisions | |
| ## Step 2: Check upstream changes for new environment variables | |
| Fetch and review the upstream README to check for any new environment variables: | |
| - Fetch https://raw.githubusercontent.com/jlesage/docker-firefox/master/README.md | |
| - Look at the "Environment Variables" section | |
| - Compare with the current environment variables in firefox/DOCS.md and firefox/config.yaml | |
| ## Step 3: Update files | |
| 1. **firefox/build.yaml**: Update the build_from image tags to use ${{ needs.check-upstream.outputs.latest_tag }} | |
| 2. **firefox/config.yaml**: | |
| - Do NOT change the `version` field β the version bump happens automatically after a successful build. | |
| - If there are NEW environment variables in upstream that are not yet in the addon, add them to the `schema` and `options` sections following the existing pattern | |
| 3. **firefox/.next-version**: | |
| - Create this file with ONLY the new version number (nothing else) | |
| - Determine the version following these rules: | |
| - PATCH version (e.g., 1.9.0 β 1.9.1): for upstream updates that only contain baseimage changes | |
| - MINOR version (e.g., 1.9.0 β 1.10.0): when new environment variables are added OR the upstream release contains Firefox-specific changes | |
| - Example content: `1.10.1` | |
| 4. **firefox/DOCS.md**: | |
| - If there are NEW environment variables, add them to the Configuration section following the existing table format and descriptions | |
| 5. **firefox/translations/en.yaml** (and other translation files in firefox/translations/): | |
| - If there are NEW environment variables, add their name and description translations following the existing pattern | |
| - Check the structure of existing entries and replicate it for new variables | |
| 6. **firefox/CHANGELOG.md**: | |
| - Add a new entry documenting the upstream update | |
| - IMPORTANT: Include the changes from ALL intermediate upstream releases you fetched in Step 1 (from ${{ needs.check-upstream.outputs.tracked_version }} to ${{ needs.check-upstream.outputs.latest_tag }}), not just the latest release | |
| - Format: "Base image update: jlesage/docker-firefox to ${{ needs.check-upstream.outputs.latest_tag }}" followed by the combined upstream changes from all intermediate releases | |
| - Look at previous changelog entries (e.g., 1.7.0, 1.8.0) to see how upstream changes are formatted | |
| - If new environment variables were added, mention them in the changelog | |
| 7. **.upstream-version**: Update to ${{ needs.check-upstream.outputs.latest_tag }} | |
| 8. Check **firefox_edge/** folder for similar updates if needed (build.yaml, config.yaml, translations/, DOCS.md, CHANGELOG.md) | |
| ## Important | |
| - Look at the git history and existing file formats to follow the same patterns | |
| - For new environment variables, follow the naming convention and structure used in previous commits | |
| - Only add environment variables that make sense for Home Assistant users | |
| - Make sure translations are consistent across all translation files | |
| - Provide a summary of what was changed, especially if new environment variables were added | |
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Commit and Push changes | |
| id: commit | |
| if: steps.pr_check.outputs.skip != 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.check-upstream.outputs.latest_tag }}" | |
| BRANCH_NAME="${{ needs.check-upstream.outputs.branch_name }}" | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "No changes detected" | |
| echo "changes_made=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Remove any output.txt that Claude might have created | |
| rm -f output.txt | |
| git add -A | |
| git commit -m "chore: update to upstream docker-firefox $VERSION" | |
| # Set up authenticated remote URL | |
| git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" | |
| git push origin "$BRANCH_NAME" | |
| echo "changes_made=true" >> $GITHUB_OUTPUT | |
| - name: Create Pull Request | |
| id: create_pr | |
| if: steps.pr_check.outputs.skip != 'true' && steps.commit.outputs.changes_made == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.check-upstream.outputs.latest_tag }}" | |
| BRANCH_NAME="${{ needs.check-upstream.outputs.branch_name }}" | |
| TRACKED="${{ needs.check-upstream.outputs.tracked_version }}" | |
| PR_URL=$(gh pr create \ | |
| --title "π Update to jlesage/docker-firefox $VERSION" \ | |
| --body "## Automated Upstream Sync | |
| **New upstream release:** [\`$VERSION\`](https://github.com/jlesage/docker-firefox/releases/tag/$VERSION) | |
| **Previous tracked version:** \`$TRACKED\` | |
| This PR updates the Firefox Home Assistant add-on to use the latest upstream Docker image. | |
| All intermediate releases between \`$TRACKED\` and \`$VERSION\` are included in the changelog. | |
| ### Checklist | |
| - [ ] Review the changes in \`firefox/\` folder | |
| - [ ] Check CHANGELOG.md entry covers all intermediate releases | |
| - [ ] Verify new environment variables (if any) | |
| --- | |
| *Created automatically by Claude Code*" \ | |
| --base main \ | |
| --head "$BRANCH_NAME") | |
| # Extract PR number from URL | |
| PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') | |
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| echo "Created PR #$PR_NUMBER" | |
| # Note: Release creation happens after PR merge via create-release.yml | |
| # Release notes are generated from CHANGELOG.md which Claude already updated |