Skip to content

Commit

Permalink
Mistake with deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Jun 16, 2024
1 parent 378d86e commit c2951ca
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 31 deletions.
73 changes: 42 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ jobs:
fail-fast: false
matrix:
include:
- name: Windows
uses: windows-latest
ocaml:
ocaml-compiler: ocaml-variants.5.1.1+options,ocaml-option-mingw
# Copied from https://github.com/ocaml-multicore/eio/blob/main/.github/workflows/main.yml
opam-depext: false
opam-repositories: |
dra27: https://github.com/dra27/opam-repository.git#windows-5.0
normal: https://github.com/ocaml/opam-repository.git
input-file: illuaminate.exe
output-file: illuaminate-windows-x86_64.exe
dune-flags:
# - name: Windows
# uses: windows-latest
# ocaml:
# ocaml-compiler: ocaml-variants.5.1.1+options,ocaml-option-mingw
# # Copied from https://github.com/ocaml-multicore/eio/blob/main/.github/workflows/main.yml
# opam-depext: false
# opam-repositories: |
# dra27: https://github.com/dra27/opam-repository.git#windows-5.0
# normal: https://github.com/ocaml/opam-repository.git
# input-file: illuaminate.exe
# output-file: illuaminate-windows-x86_64.exe
# dune-flags:

- name: Linux
uses: ubuntu-latest
Expand All @@ -49,13 +49,13 @@ jobs:
output-file: illuaminate-linux-x86_64
dune-flags: --workspace dune-workspace.release

- name: macOS
uses: macos-latest
ocaml:
ocaml-compiler: "5.1.1"
input-file: illuaminate
output-file: illuaminate-macos-x86_64
dune-flags:
# - name: macOS
# uses: macos-latest
# ocaml:
# ocaml-compiler: "5.1.1"
# input-file: illuaminate
# output-file: illuaminate-macos-x86_64
# dune-flags:

name: Build ${{ matrix.name }}
runs-on: ${{ matrix.uses }}
Expand Down Expand Up @@ -98,22 +98,33 @@ jobs:
name: Upload Archives
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
# if: github.ref == 'refs/heads/master'

permissions:
id-token: write

environment:
name: website
# url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download executable
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Upload
run: .github/workflows/deploy.sh 2> /dev/null
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT }}
run: node action.js


# - name: Download executable
# uses: actions/download-artifact@v4
# with:
# path: artifacts

# - name: Upload
# run: .github/workflows/deploy.sh 2> /dev/null
# env:
# SSH_KEY: ${{ secrets.SSH_KEY }}
# SSH_USER: ${{ secrets.SSH_USER }}
# SSH_HOST: ${{ secrets.SSH_HOST }}
# SSH_PORT: ${{ secrets.SSH_PORT }}
31 changes: 31 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

// action.ts
var setFailed = (msg) => {
process.stdout.write(`::error::${msg}
`);
process.exit(1);
};
(async () => {
const token = process.env["ACTIONS_ID_TOKEN_REQUEST_TOKEN"];
if (!token) return setFailed("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable");
const tokenUrl = process.env["ACTIONS_ID_TOKEN_REQUEST_URL"];
if (!tokenUrl) return setFailed("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable");
const tokenResponse = await fetch(tokenUrl, { headers: { "Authorization": `Bearer ${token}` } }).then((x) => x.json());
const idToken = tokenResponse?.value;
if (!idToken) return setFailed("Could not fetch token");
const response = await fetch("https://squiddev.cc/~deploy", {
headers: {
"Authorization": `Bearer ${idToken}`,
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({})
});
if (response.status != 201) {
const body2 = await response.text().catch((e) => `${e}`);
setFailed(`Failed to deploy site with HTTP status: ${response.status}: ${body2}`);
}
const body = await response.text();
console.log(body);
})();

0 comments on commit c2951ca

Please sign in to comment.