Skip to content

Commit

Permalink
Merge pull request #2 from bekk/codepush_timestamp
Browse files Browse the repository at this point in the history
✨ Legger til tidsstempel for codepush
  • Loading branch information
leiferikbjorkli authored Sep 4, 2023
2 parents f78b28e + 94ff05b commit cefa491
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
root: true,
extends: '@react-native',
rules: {
'react-native/no-inline-styles': 0,
},
};
7 changes: 5 additions & 2 deletions .github/workflows/build-custom-codepush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ jobs:
- name: NPM install CI
run: npm ci

- id: timestamp
run: echo "::set-output name=timestamp::$(date +%d%m%H%M)"

- name: Bygg CodePush
run: |
npx appcenter login --token ${{ secrets.APPCENTER_API_TOKEN }}
npx appcenter codepush release-react -a leif.erik.bjorkli-BEKK.no/RNSkolenApp -d Staging -t ${{ github.event.inputs.targetVersion }}
npx appcenter codepush release-react -a leif.erik.bjorkli-BEKK.no/RNSkolenApp-Android -d Staging -t ${{ github.event.inputs.targetVersion }}
npx appcenter codepush release-react -a leif.erik.bjorkli-BEKK.no/RNSkolenApp -d Staging -t ${{ github.event.inputs.targetVersion }} --description "${{ github.event.inputs.targetVersion }}-${{ steps.timestamp.outputs.timestamp }}"
npx appcenter codepush release-react -a leif.erik.bjorkli-BEKK.no/RNSkolenApp-Android -d Staging -t ${{ github.event.inputs.targetVersion }} --description "${{ github.event.inputs.targetVersion }}-${{ steps.timestamp.outputs.timestamp }}"
16 changes: 13 additions & 3 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import {
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import {useCodePushDescription} from './Utils';

type SectionProps = PropsWithChildren<{
title: string;
Expand Down Expand Up @@ -56,10 +56,11 @@ function Section({children, title}: SectionProps): JSX.Element {
}

function App(): JSX.Element {
const codePushDescription = useCodePushDescription();
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: 'blue',
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
Expand All @@ -71,7 +72,16 @@ function App(): JSX.Element {
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
position: 'absolute',
top: 5,
right: 10,
elevation: 1,
zIndex: 1,
}}>
<Text>{codePushDescription}</Text>
</View>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
Expand Down
19 changes: 19 additions & 0 deletions app/Utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {useEffect, useState} from 'react';
import codePush from 'react-native-code-push';

export function useCodePushDescription() {
const [description, setDescription] = useState<string>('No codepush');

useEffect(() => {
setCodePushDescription();
}, []);

async function setCodePushDescription() {
const codePushMetadata = await codePush.getUpdateMetadata();
if (codePushMetadata && codePushMetadata.description) {
setDescription(codePushMetadata.description);
}
}

return description;
}

0 comments on commit cefa491

Please sign in to comment.