55 branches :
66 - main
77 tags :
8- - ' v* '
8+ - " v* "
99 workflow_dispatch :
1010
1111env :
12- IMAGE_NAME : pypsa-app
1312 REGISTRY : ghcr.io
13+ FULL_IMAGE_NAME : ghcr.io/pypsa/pypsa-app
1414
1515jobs :
16- push-full- image :
17- name : Build and push full image
16+ push-image :
17+ name : Build and push image
1818 runs-on : ubuntu-latest
1919 permissions :
2020 contents : read
3838 id : meta
3939 uses : docker/metadata-action@v5
4040 with :
41- images : ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
41+ images : ${{ env.FULL_IMAGE_NAME }}
4242 tags : |
4343 type=ref,event=branch
4444 type=ref,event=tag
4747 type=sha,prefix=
4848 type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
4949
50- - name : Build and push full Docker image
50+ - name : Build and push Docker image
5151 uses : docker/build-push-action@v5
5252 with :
5353 context : .
@@ -57,11 +57,26 @@ jobs:
5757 tags : ${{ steps.meta.outputs.tags }}
5858 labels : ${{ steps.meta.outputs.labels }}
5959
60- - name : Image summary
60+ - name : Tag main with version image
61+ if : startsWith(github.ref, 'refs/tags/v')
6162 run : |
62- echo "Image: \`${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
63- echo "" >> $GITHUB_STEP_SUMMARY
64- echo "Tags:" >> $GITHUB_STEP_SUMMARY
65- echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
66- echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
67- echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
63+ # Pull the versioned image
64+ docker pull ${{ env.FULL_IMAGE_NAME }}:${{ github.ref_name }}
65+
66+ # Tag it as main and push
67+ docker tag ${{ env.FULL_IMAGE_NAME }}:${{ github.ref_name }} ${{ env.FULL_IMAGE_NAME }}:main
68+ docker push ${{ env.FULL_IMAGE_NAME }}:main
69+
70+ deploy-to-dev :
71+ name : Deploy to dev server
72+ runs-on : ubuntu-latest
73+ needs : push-image
74+ steps :
75+ - name : Deploy via SSH
76+ 77+ with :
78+ host : ${{ secrets.SSH_HOST }}
79+ username : ${{ secrets.SSH_USER }}
80+ key : ${{ secrets.SSH_PRIVATE_KEY }}
81+ # Dummy command
82+ script : whoami
0 commit comments