Repository navigation
Restrict production deployment transport and sandbox administration #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,53 @@ | ||
| name: Production Backup | ||
|
|
||
| # The nightly run is a fixed host crontab entry (see deploy/production/README.md): | ||
| # scheduled workflows start hours late and then overlap daytime traffic. This workflow | ||
| # is for manual backups. | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: production-backup | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: {} | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| backup: | ||
| name: Back up production state | ||
| runs-on: ubuntu-22.04 | ||
| environment: production | ||
| timeout-minutes: 180 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Require repository owner for manual runs | ||
| if: ${{ github.event_name == 'workflow_dispatch' }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ "${{ github.actor }}" != "iamwavecut" || "${{ github.triggering_actor }}" != "iamwavecut" ]]; then | ||
| echo "Production backup can only be started or re-run manually by iamwavecut" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
|
||
| - name: Configure SSH | ||
| shell: bash | ||
| - name: Require repository owner and main | ||
| env: | ||
| GETA_SSH_PRIVATE_KEY: ${{ secrets.GETA_SSH_PRIVATE_KEY }} | ||
| GETA_SSH_KNOWN_HOSTS: ${{ secrets.GETA_SSH_KNOWN_HOSTS }} | ||
| GETA_SSH_PORT: ${{ vars.GETA_SSH_PORT || '22022' }} | ||
| ACTOR: ${{ github.actor }} | ||
| TRIGGERING_ACTOR: ${{ github.triggering_actor }} | ||
| RELEASE_REF: ${{ github.ref }} | ||
| run: | | ||
| set -euo pipefail | ||
| test -n "$GETA_SSH_PRIVATE_KEY" | ||
| test -n "$GETA_SSH_KNOWN_HOSTS" | ||
| install -m 700 -d "$HOME/.ssh" | ||
| printf '%s\n' "$GETA_SSH_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts" | ||
| chmod 600 "$HOME/.ssh/known_hosts" | ||
| printf 'Host geta.moe 207.244.239.212 2605:a140:2260:6080::1\n Port %s\n' "$GETA_SSH_PORT" > "$HOME/.ssh/config" | ||
| chmod 600 "$HOME/.ssh/config" | ||
| eval "$(ssh-agent -s)" | ||
| printf '%s\n' "$GETA_SSH_PRIVATE_KEY" | ssh-add - | ||
| echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> "$GITHUB_ENV" | ||
| echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Upload backup script | ||
| shell: bash | ||
| [[ "$ACTOR" == iamwavecut && "$TRIGGERING_ACTOR" == iamwavecut ]] | ||
| [[ "$RELEASE_REF" == refs/heads/main ]] | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Configure pinned SSH identity | ||
| env: | ||
| GETA_SSH_TARGET: ${{ secrets.GETA_SSH_TARGET }} | ||
| GETA_DEPLOY_ROOT: ${{ secrets.GETA_DEPLOY_ROOT }} | ||
| SSH_KEY: ${{ secrets.GETA_SSH_PRIVATE_KEY }} | ||
| KNOWN_HOSTS: ${{ secrets.GETA_SSH_KNOWN_HOSTS }} | ||
| SSH_PORT: ${{ vars.GETA_SSH_PORT || '22022' }} | ||
| run: | | ||
| set -euo pipefail | ||
| # shellcheck disable=SC2029 | ||
| ssh "$GETA_SSH_TARGET" "install -d -m 755 '$GETA_DEPLOY_ROOT'" | ||
| scp deploy/production/backup-production.sh "$GETA_SSH_TARGET:$GETA_DEPLOY_ROOT/backup-production.sh" | ||
| # shellcheck disable=SC2029 | ||
| ssh "$GETA_SSH_TARGET" "chmod 755 '$GETA_DEPLOY_ROOT/backup-production.sh'" | ||
|
|
||
| - name: Create production backup | ||
| shell: bash | ||
| install -m 700 -d ~/.ssh | ||
| printf '%s\n' "$SSH_KEY" > ~/.ssh/geta_deploy | ||
| chmod 600 ~/.ssh/geta_deploy | ||
| printf '%s\n' "$KNOWN_HOSTS" > ~/.ssh/known_hosts | ||
| chmod 600 ~/.ssh/known_hosts | ||
| printf 'Host geta.moe\n Port %s\n IdentitiesOnly yes\n BatchMode yes\n StrictHostKeyChecking yes\n' "$SSH_PORT" > ~/.ssh/config | ||
| - name: Request fixed host backup procedure | ||
| env: | ||
| GETA_SSH_TARGET: ${{ secrets.GETA_SSH_TARGET }} | ||
| GETA_DEPLOY_ROOT: ${{ secrets.GETA_DEPLOY_ROOT }} | ||
| DEPLOY_OPERATION: backup | ||
| run: | | ||
| set -euo pipefail | ||
| ssh \ | ||
| -o ServerAliveInterval=30 \ | ||
| -o ServerAliveCountMax=120 \ | ||
| "$GETA_SSH_TARGET" \ | ||
| "'$GETA_DEPLOY_ROOT/backup-production.sh'" | ||
| python3 scripts/geta-deploy-request.py | | ||
| ssh -T -i ~/.ssh/geta_deploy -o ServerAliveInterval=30 -o ServerAliveCountMax=360 \ | ||
| deploy@geta.moe backup |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The GHCR pull token is no longer sent and the contract sets
registry_auth: false,but the image is pushed under
ghcr.io/iamwavecut/openplotvausing the ephemeralGITHUB_TOKEN. If that package is private, the host broker cannot pull it and thedeployment will fail. Confirm the package is public or arrange an authenticated
pull path on the host. [general, importance: 5]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed through the package API: ghcr.io/iamwavecut/openplotva is public. Anonymous host pulls are intentional; the production README now states this explicitly.