-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1348 from dedis/work-fe1-web-nkocher-deploy-action
Adds a deploy action and some build info
- Loading branch information
Showing
10 changed files
with
192 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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,71 @@ | ||
# Triggers a new deployment when a release starting with "fe1-" is created. | ||
|
||
name: Release and deployment of fe1-web | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
deploy: | ||
if: ${{ startsWith(github.event.release.tag_name, 'fe1-') }} | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
base_folder: fe1-web | ||
|
||
defaults: | ||
run: | ||
working-directory: ./${{ env.base_folder }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
# Save some build information to inject into the APP | ||
- name: Get the version | ||
id: get_version | ||
run: | | ||
echo ::set-output name=version::$(echo ${GITHUB_REF/refs\/tags\//}) | ||
echo ::set-output name=version_file::$(echo ${GITHUB_REF/refs\/tags\//} | tr . _) | ||
echo "::set-output name=shortsha::$(git rev-parse --short ${GITHUB_SHA})" | ||
echo "::set-output name=buildurl::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}" | ||
echo "::set-output name=date::$(date +'%d/%m/%y %H:%M')" | ||
- name: install | ||
run: | | ||
npm install | ||
# Will create a 'web-build/' folder containing the App | ||
- name: transpile | ||
env: | ||
APP_VERSION: ${{ steps.get_version.outputs.version }} | ||
APP_SHORT_SHA: ${{ steps.get_version.outputs.shortsha }} | ||
APP_BUILD_URL: ${{ steps.get_version.outputs.buildurl }} | ||
APP_BUILD_DATE: ${{ steps.get_version.outputs.date }} | ||
run: | | ||
npm run build-web | ||
- name: Create tar.gz | ||
run: | | ||
tar -czvf fe1_web_${{ steps.get_version.outputs.version_file }}.tar.gz ./web-build | ||
- name: Upload release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: ${{ env.base_folder }}/fe1_web_${{ steps.get_version.outputs.version_file }}.tar.gz | ||
|
||
# Use rsync to deploy the new website | ||
- name: Sync | ||
env: | ||
dest: "fe1pop@${{secrets.FE1_DEPLOY_ADDR}}:www" | ||
run: | | ||
echo "${{secrets.FE1_DEPLOY_KEY}}" > deploy_key | ||
chmod 600 ./deploy_key | ||
rsync -chav --delete \ | ||
-e 'ssh -p ${{secrets.FE1_DEPLOY_PORT}} -i ./deploy_key -o StrictHostKeyChecking=no' \ | ||
./web-build/ ${{env.dest}} |
This file contains 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 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 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,43 @@ | ||
import Constants from 'expo-constants'; | ||
import React from 'react'; | ||
import { StyleSheet, View, Linking, Text, ViewStyle } from 'react-native'; | ||
|
||
import { Spacing, Typography } from 'core/styles'; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
position: 'absolute', | ||
bottom: Spacing.x05, | ||
left: Spacing.x05, | ||
zIndex: 100, | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
} as ViewStyle, | ||
}); | ||
|
||
const BuildInfo = () => { | ||
return ( | ||
<View style={styles.container}> | ||
<Text | ||
style={[Typography.minuscule, Typography.inactive, Typography.code, Typography.uppercase]}> | ||
<Text | ||
onPress={() => | ||
Linking.openURL( | ||
`https://github.com/dedis/popstellar/releases/tag/${Constants?.expoConfig?.extra?.appVersion}`, | ||
) | ||
}> | ||
{Constants?.expoConfig?.extra?.appVersion} | ||
</Text> | ||
<Text> | </Text> | ||
<Text onPress={() => Linking.openURL(Constants?.expoConfig?.extra?.buildURL)}> | ||
{Constants?.expoConfig?.extra?.shortSHA} | ||
</Text> | ||
<Text> | </Text> | ||
<Text>{Constants?.expoConfig?.extra?.buildDate}</Text> | ||
</Text> | ||
</View> | ||
); | ||
}; | ||
|
||
export default BuildInfo; |
This file contains 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,11 @@ | ||
import { render } from '@testing-library/react-native'; | ||
import React from 'react'; | ||
|
||
import BuildInfo from '../BuildInfo'; | ||
|
||
describe('BuildInfo', () => { | ||
it('renders correctly', () => { | ||
const { toJSON } = render(<BuildInfo />); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
fe1-web/src/core/components/__tests__/__snapshots__/BuildInfo.test.tsx.snap
This file contains 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,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BuildInfo renders correctly 1`] = ` | ||
<View | ||
style={ | ||
Object { | ||
"alignItems": "center", | ||
"bottom": 8, | ||
"display": "flex", | ||
"flexDirection": "row", | ||
"left": 8, | ||
"position": "absolute", | ||
"zIndex": 100, | ||
} | ||
} | ||
> | ||
<Text | ||
style={ | ||
Array [ | ||
Object { | ||
"fontSize": 8, | ||
"lineHeight": 1, | ||
}, | ||
Object { | ||
"color": "#8E8E8E", | ||
}, | ||
Object { | ||
"fontFamily": "Courier New", | ||
}, | ||
Object { | ||
"textTransform": "uppercase", | ||
}, | ||
] | ||
} | ||
> | ||
<Text | ||
onPress={[Function]} | ||
/> | ||
<Text> | ||
| | ||
</Text> | ||
<Text | ||
onPress={[Function]} | ||
/> | ||
<Text> | ||
| | ||
</Text> | ||
<Text /> | ||
</Text> | ||
</View> | ||
`; |
This file contains 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 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 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 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