add: parse container id #10
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
name: Build & Deploy to Scaleway | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Scaleway Container Registry | |
uses: docker/login-action@v3 | |
with: | |
username: nologin | |
password: ${{ secrets.SCALEWAY_SECRET_KEY }} | |
registry: ${{ secrets.SCALEWAY_CONTAINER_REGISTRY_ENDPOINT }} | |
- name: Build the Docker image | |
run: docker build . -t ${{ secrets.SCALEWAY_CONTAINER_REGISTRY_ENDPOINT }}/webapp:latest | |
- name: Push the Docker Image | |
run: docker push ${{ secrets.SCALEWAY_CONTAINER_REGISTRY_ENDPOINT }}/webapp:latest | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy on Scaleway Containers | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Scaleway CLI image | |
id: pull | |
run: docker pull scaleway/cli:2.28 | |
- name: Get Container ID | |
id: list | |
run: | | |
docker run -i --rm \ | |
-e SCW_ACCESS_KEY=${{ secrets.SCALEWAY_ACCESS_KEY }} \ | |
-e SCW_SECRET_KEY=${{ secrets.SCALEWAY_SECRET_KEY }} \ | |
-e SCW_DEFAULT_ORGANIZATION_ID=${{ secrets.SCALEWAY_ORGANIZATION_ID }} \ | |
scaleway/cli:latest container container list name=${{ secrets.CONTAINER_NAME }} --output json | |
- name: Update Container | |
id: update | |
run: | | |
docker run -i --rm \ | |
-e SCW_ACCESS_KEY=${{ secrets.SCALEWAY_ACCESS_KEY }} \ | |
-e SCW_SECRET_KEY=${{ secrets.SCALEWAY_SECRET_KEY }} \ | |
-e SCW_DEFAULT_ORGANIZATION_ID=${{ secrets.SCALEWAY_ORGANIZATION_ID }} \ | |
scaleway/cli:latest container container update ${{ env.CONTAINER_ID }} \ | |
registry-image=${{ secrets.SCALEWAY_CONTAINER_REGISTRY_ENDPOINT }}/webapp:latest |