Skip to content

Commit

Permalink
implement cd
Browse files Browse the repository at this point in the history
  • Loading branch information
TuuKeZu committed Aug 16, 2024
1 parent 975c294 commit 4990167
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 7 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create and publish a Docker image

on:
push:
branches: ['release']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
3 changes: 2 additions & 1 deletion src/compontents/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { useNavigate } from 'react-router-dom';
import { BlurLayer } from '../LoadingScreen/LoadingScreen';
import { useVersion } from '../../features/version/versionSlice';

const { versionLabel } = require('../../config.json');
const { REACT_APP_VERSION_LABEL } = process.env;
const versionLabel = REACT_APP_VERSION_LABEL;


export default function Login() {
Expand Down
14 changes: 10 additions & 4 deletions src/features/authentication/authSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import { handleError } from '../errors/errorSlice';
import crypto from 'crypto-js';

import config from '../../config.json'
const { REACT_APP_SIGNATURE } = process.env;
const signature = REACT_APP_SIGNATURE;

export const loginToWilma = createAsyncThunk(
'auth/loginToWilma',
Expand Down Expand Up @@ -77,11 +78,16 @@ export const setAgreement = () => {

export const getSavedCredentials = () => {
const encrypted = window.localStorage.getItem('saved-credentials');
if(!encrypted) window.localStorage.setItem('saved-credentials', null);
if(!encrypted) {
window.localStorage.setItem('saved-credentials', null);
return null;
}

if (encrypted === "null") return null;

console.log(encrypted);

const decrypted = crypto.AES.decrypt(encrypted, config.signature).toString(crypto.enc.Utf8);
const decrypted = crypto.AES.decrypt(encrypted, signature).toString(crypto.enc.Utf8);
try {
const credentials = JSON.parse(decrypted);
return credentials;
Expand All @@ -93,7 +99,7 @@ export const getSavedCredentials = () => {

export const setSavedCredentials = (credentials) => {
const raw = JSON.stringify(credentials);
const encrypted = crypto.AES.encrypt(raw, config.signature);
const encrypted = crypto.AES.encrypt(raw, signature);

return window.localStorage.setItem('saved-credentials', encrypted);
}
Expand Down
1 change: 1 addition & 0 deletions src/features/themes/themeSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const loadThemeDefault = createAsyncThunk(
'themes/loadThemeDefault',
async (options, thunkAPI) => {
return await new Promise((resolve, reject) => {
console.log(process.env);
const themes = thunkAPI.getState().themes;
const id = options['id'];

Expand Down
3 changes: 2 additions & 1 deletion src/requests/theme-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
cacheAvailable
} from './utility'

const { otaWilmaApi } = require('../config.json');
const { REACT_APP_OTAWILMA_API } = process.env;
const otaWilmaApi = REACT_APP_OTAWILMA_API;


const login = (auth) => {
Expand Down
3 changes: 2 additions & 1 deletion src/requests/wilma-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {

import { login as loginToOtaWilma } from './theme-api'

const { wilmaApi } = require('../config.json');
const { REACT_APP_WILMA_API } = process.env;
const wilmaApi = REACT_APP_WILMA_API;

const login = (credentials) => {
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 4990167

Please sign in to comment.