diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8ba7517 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,91 @@ +name: Component Deploy + +on: + pull_request: + +env: + ARCCTL_CACHE_KEY: arcctl-0.3.1 # Hardcoding a version number here so we don't keep downloading this + ARC_DATACENTER: gh-datacenter # gh-serverless-dc + ARC_ENVIRONMENT: ./environments/qa.yml + GCP_ACCOUNT_NAME: gcp-test + GCP_PROJECT: permanent-environment-testing + COMPONENT_NAME: tyleraldrich/twitter-clone:latest + XDG_CONFIG_HOME: ./arcctl-config/ + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: arcctl binary + id: arcctl-cache + uses: actions/cache@v3 + with: + path: ./arcctl + key: ${{ env.ARCCTL_CACHE_KEY }} + - if: ${{ steps.arcctl-cache.outputs.cache-hit != 'true' }} + name: Download arcctl + run: curl -SL https://arcctl-dcs.nyc3.digitaloceanspaces.com/arcctl --output arcctl + - name: Make arcctl executable + run: chmod +x ./arcctl + - name: arcctl config + uses: actions/cache@v3 + with: + path: ${{ env.XDG_CONFIG_HOME }} + key: ${{ github.event.pull_request.number }} + - name: Setup arcctl backend + run: ./arcctl set state.backend --provider s3 --creds accessKeyId=${{ secrets.BUCKET_ACCESS_KEY_ID }} --creds secretAccessKey=${{ secrets.BUCKET_ACCESS_KEY }} --creds endpoint=https://nyc3.digitaloceanspaces.com --creds region=nyc3 --namespace arcctl-dcs + build_component: + runs-on: ubuntu-latest + needs: setup + steps: + - uses: actions/checkout@v3 + - name: Load arcctl binary + id: arcctl-cache + uses: actions/cache@v3 + with: + path: ./arcctl + key: ${{ env.ARCCTL_CACHE_KEY }} + - name: arcctl config + uses: actions/cache@v3 + with: + path: ${{ env.XDG_CONFIG_HOME }} + key: ${{ github.event.pull_request.number }} + - name: Docker Login + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build component + run: ./arcctl build architect.yml -t ${{ env.COMPONENT_NAME }} + - name: Push component + run: ./arcctl push ${{ env.COMPONENT_NAME }} + deploy_component: + runs-on: ubuntu-latest + needs: build_component + steps: + - uses: actions/checkout@v3 + - id: auth + name: Authenticate to Google Cloud + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} + create_credentials_file: true + # Install gcloud, `setup-gcloud` automatically picks up authentication from `auth`. + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v1 + - name: Setup GKE gcloud auth plugin + run: gcloud components install gke-gcloud-auth-plugin + - name: Load arcctl binary + id: arcctl-cache + uses: actions/cache@v3 + with: + path: ./arcctl + key: ${{ env.ARCCTL_CACHE_KEY }} + - name: arcctl config + uses: actions/cache@v3 + with: + path: ${{ env.XDG_CONFIG_HOME }} + key: ${{ github.event.pull_request.number }} + - name: Apply environment + run: ./arcctl apply env qa-${{ github.event.pull_request.number }} ${{ env.ARC_ENVIRONMENT }} -d ${{ env.ARC_DATACENTER}} --auto-approve diff --git a/.gitignore b/.gitignore index 8f322f0..4fa3d54 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +secret/ diff --git a/app/(home)/home-yeet-form.tsx b/app/(home)/home-yeet-form.tsx index 5dfd44f..4303d24 100644 --- a/app/(home)/home-yeet-form.tsx +++ b/app/(home)/home-yeet-form.tsx @@ -21,9 +21,9 @@ export const HomeYeetForm = () => { body: JSON.stringify({ message, }), + }).then(() => { + location.reload(); }); - - location.reload(); }; return session ? ( diff --git a/app/(home)/page.tsx b/app/(home)/page.tsx index 51e0dd6..bb27b45 100644 --- a/app/(home)/page.tsx +++ b/app/(home)/page.tsx @@ -5,8 +5,8 @@ import { PageHeader } from '../_components/page-header'; import { HomeYeetForm } from './home-yeet-form'; export const metadata: Metadata = { - title: 'The Y Feed', - description: 'A list of messages yeeted into the ether', + title: 'Y Feed', + description: 'A list of messages yeeted into the ether!', }; const HomePage = () => { diff --git a/app/_components/app-layout.tsx b/app/_components/app-layout.tsx index 9e32bf0..4df0826 100644 --- a/app/_components/app-layout.tsx +++ b/app/_components/app-layout.tsx @@ -18,6 +18,7 @@ import { import { Button } from './button'; import { classNames, getGravatarImageUrl } from './utils'; import { Avatar } from './avatar'; +import { oryUserAddr } from '../ory'; export const useAppSelector: TypedUseSelectorHook = useSelector; @@ -81,10 +82,7 @@ export const AppLayout = ({ children }: React.PropsWithChildren) => { navigation.push( { name: 'Sign in', - href: - process.env.NEXT_PUBLIC_USER_SERVICE_ADDR?.replace(/\/$/, '') + - '/login?return_to=' + - returnTo, + href: `${oryUserAddr}/login?return_to=${returnTo}`, icon: UserIcon, current: false, inverted: false, @@ -92,12 +90,7 @@ export const AppLayout = ({ children }: React.PropsWithChildren) => { }, { name: 'Sign up', - href: - process.env.NEXT_PUBLIC_USER_SERVICE_ADDR?.replace(/\/$/, '') + - '/registration?return_to=' + - returnTo + - '&after_verification_return_to=' + - returnTo, + href: `${oryUserAddr}/registration?return_to=${returnTo}&after_verification_return_to=${returnTo}`, icon: UserIcon, current: false, inverted: true, diff --git a/app/_components/button.tsx b/app/_components/button.tsx index ea0efb2..3804871 100644 --- a/app/_components/button.tsx +++ b/app/_components/button.tsx @@ -42,5 +42,6 @@ export const Button = (props: ButtonProps) => { } const btn =