-
Notifications
You must be signed in to change notification settings - Fork 72
Add deployment automation #961
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 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c3b48e0
Add deployment logic
egeakman dbc36cf
Update deploy.yml
cybit 5f11455
Update deploy.yml
cybit b4182ff
Update deploy.yml
cybit 4a7799c
Update deploy.yml
cybit 7cf4f81
Update deploy.yml
cybit 9af2130
Update deploy.yml
cybit 6773634
Update deploy.yml
cybit 5366576
Update deploy.yml
cybit 90d34fb
Update deploy.yml
cybit e53780f
Update deploy.yml
cybit 0bd390d
Update deploy.yml
cybit 80f5ef8
Update deploy.yml
cybit 7a624cc
Update deploy.yml
cybit 00b5d11
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3ea643d
Update deploy.yml
cybit f291dca
test simpler deployment (#965)
artcz 3692aee
Update src/components/footer.astro
artcz 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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Deploy to Server | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - ep2025 | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set timestamp for build/deploy | ||
| run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install dependencies | ||
| run: make install | ||
|
|
||
| - name: Build the website | ||
| run: make build | ||
|
|
||
| - name: Set up SSH key | ||
| uses: webfactory/[email protected] | ||
| with: | ||
| ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }} | ||
|
|
||
| - name: ssh keyscan | ||
| run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts | ||
|
|
||
| - name: Deploy to server | ||
| run: make deploy FORCE_DEPLOY=true |
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 |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| name: Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| preview: | ||
| name: Run preview | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PREVIEW_HOSTNAME: ep-preview.click | ||
| GITHUB_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set timestamp for build/deploy | ||
| run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install dependencies | ||
| run: make install | ||
|
|
||
| - name: Build the website | ||
| run: make build | ||
|
|
||
| - name: Set up SSH key | ||
| uses: webfactory/[email protected] | ||
| with: | ||
| ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }} | ||
|
|
||
| - name: Get current branch name | ||
| run: | | ||
| BRANCH_NAME=$(make safe_branch BRANCH=$GITHUB_BRANCH_NAME) | ||
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | ||
|
|
||
| - name: ssh keyscan | ||
| run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts | ||
|
|
||
| - name: Upload preview | ||
| run: make preview BRANCH=$GITHUB_BRANCH_NAME | ||
|
|
||
| - name: Update PR Comment | ||
| uses: actions/github-script@v6 | ||
| if: github.event_name == 'pull_request' | ||
|
|
||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| console.log("Hello world!"); | ||
| const pr_id = ${{ github.event.number }}; | ||
| console.log("PR Id %d", pr_id); | ||
|
|
||
| comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: Number(pr_id) | ||
| }) | ||
|
|
||
| const preview_identifier = "# Preview available" | ||
|
|
||
| let comment_id = null; | ||
| comments.forEach(comment => { | ||
| if(comment.body.indexOf(preview_identifier) >= 0) { | ||
| comment_id = comment.id; | ||
| } | ||
| }); | ||
|
|
||
| const branch_name = process.env.BRANCH_NAME; | ||
| const url = "https://" + branch_name + "." + process.env.PREVIEW_HOSTNAME; | ||
| const timestamp = new Date().toISOString(); | ||
| const header = "\n|Key|Value|\n|---|---|\n" | ||
| const body = preview_identifier + header + "|url|" + url + "|\n|last update|" + timestamp + "|"; | ||
|
|
||
| if(comment_id > 0) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: comment_id, | ||
| body: body | ||
| }); | ||
|
|
||
| } else { | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| issue_number: Number(pr_id), | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: body | ||
| }); | ||
| } |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.